Announcement

Collapse
No announcement yet.

Active Directory

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Active Directory

    There are several sample scripts for AD, but I found none so far for my requirement.

    I am trying to retrieve user properties for a list of AD users I have in a text file.

    Here is the script I have so far

    Const ForReading = 1

    'Global variables
    Dim oContainer
    Dim OutPutFile
    Dim FileSystem

    'Initialize global variables
    Set FileSystem = WScript.CreateObject("Scripting.FileSystemObject")
    Set objInputFile = FileSystem.OpenTextFile ("c:\R&D4.txt", ForReading)
    Set OutPutFile = FileSystem.CreateTextFile("R&D4Names.txt", True)

    Set objRootDSE = GetObject("LDAP://RootDSE")

    strDNSDomain = objRootDSE.Get("DefaultNamingContext")

    Set objContainer= GetObject("LDAP://OU=MENDOT,OU=MH,OU=HQ,DC=Global,DC=com")


    Do Until objInputFile.AtEndOfStream

    struser = objInputFile.ReadLine

    Set objUser = GetObject ("LDAP://cn=" & struser & ",ou=MENDOT,OU=MH,OU=HQ,DC=Global,DC=com")

    WScript.Echo objUser.displayname

    Loop


    The text file has names

    ALEXADL
    ANDERJR

    the script is failing on the second user aderrjr as in the ADUC the OU display the name as Anderson, Jay R

    Thanks
    Last edited by honsolo; 19th September 2005, 15:32.

  • #2
    Re: Active Directory

    Hi Honsolo,

    Where did the names on R&D4.txt came from?

    I'm asking in order to get the general idea of what you seek and maybe advise a better way.


    In regards to your error (which you didnt supply) I can guess that ANDERJR is not the 'cn' of that user and so the script fails.

    Comment

    Working...
    X