Hi all,
I have a script I found that ALMOST does what I need, but Im not a good scripter and could use help tweaking it.
The script asks for a user name for input. It then searchs a specific containcer in AD that I have hard coded into the script, and returns certain user attributes that it finds. The problem is I need it to search all of AD for the user, not just the container Im putting in. I think its easy to change the script to do that, if one knows what they are doing?
I have a Container called CSC, and in there a Users container. The script pulls all the info I need if the user actually is in the users container. But what if hes somewhere else..thats what I need to do.
Here is the script:
strContainer = "ou=users,ou=csc"
strName = InputBox("Enter UserID")
Const OpenFileForReading = 1
Const OpenFileForWriting = 2
On Error Resume Next
'***********************************************
'* Connect to an object *
'***********************************************
Set objRootDSE = GetObject("LDAP://rootDSE")
If strContainer = "" Then
Set objItem = GetObject("LDAP://" & _
objRootDSE.Get("defaultNamingContext"))
Else
Set objItem = GetObject("LDAP://cn=" & strName & "," & strContainer & "," & _
objRootDSE.Get("defaultNamingContext"))
End If
'***********************************************
'* End connect to an object *
'***********************************************
Set objFSO = CreateObject("Scripting.FileSystemObject")
'Set objInputFile = objFSO.openTextFile("Users.txt",OpenFileForReading)
Set objOutputFile = objFSO.CreateTextFile("c:\GetuserUsersAttrib.txt",OpenFileForWriting)
objOutputFile.writeline VbCrLf & "******* General Properties Page*******"
objOutputFile.writeline "******* (Single-Valued Attributes) *******"
strname = objItem.Get("name")
objOutputFile.writeline "name: " & strname
strgivenName = objItem.Get("givenName")
objOutputFile.writeline "givenName: " & strgivenName
strdisplayName = objItem.Get("displayName")
objOutputFile.writeline "displayName: " & strdisplayName
struserPrincipalName = objItem.Get("userPrincipalName")
objOutputFile.writeline "userPrincipalName: " & struserPrincipalName
strdescription = objItem.Get("description")
objOutputFile.writeline "description: " & strdescription
strtelephoneNumber = objItem.Get("telephoneNumber")
objOutputFile.writeline "telephoneNumber: " & strtelephoneNumber
strmail = objItem.Get("mail")
objOutputFile.writeline "mail: " & strmail
objOutputFile.writeline VbCrLf & "******* CSC Specific Information*******"
objOutputFile.writeline "******* (Single-Valued Attributes) *******"
strEmployeeID = objItem.Get("EmployeeID")
objOutputFile.writeline "EmployeeID: " & strEmployeeID
strEmployeeNumber = objItem.Get("EmployeeNumber")
objOutputFile.writeline "EmployeeNumber: " & strEmployeeNumber
strEmployeeType = objItem.Get("EmployeeType")
objOutputFile.writeline "EmployeeType: " & strEmployeeType
objOutputFile.writeline VbCrLf & "******* Address Properties Page*******"
objOutputFile.writeline "******* (Single-Valued Attributes) *******"
strstreetAddress = objItem.Get("streetAddress")
objOutputFile.writeline "streetAddress: " & strstreetAddress
strl = objItem.Get("l")
objOutputFile.writeline "l: " & strl
strst = objItem.Get("st")
objOutputFile.writeline "st: " & strst
strpostalCode = objItem.Get("postalCode")
objOutputFile.writeline "postalCode: " & strpostalCode
objOutputFile.writeline VbCrLf & "******* Account Properties Page*******"
objOutputFile.writeline "******* (The userAccountControl attribute) *******"
If err.Number = -2147467259 OR _
objItem.AccountExpirationDate = "1/1/1970" Then
objOutputFile.writeline "Account doesn't expire."
Else
objOutputFile.writeline "Account expires on: " & objItem.AccountExpirationDate
End If
objOutputFile.writeline VbCrLf & "******* Member Of Properties Page*******"
objOutputFile.writeline "******* (MultiValued Attributes) *******"
strmemberOf = objItem.GetEx("memberOf")
objOutputFile.writeline "memberOf:"
For Each Item in strmemberOf
objOutputFile.writeline vbTab & Item
Next
objOutputFile.writeline VbCrLf & "******* Object Properties Page*******"
objOutputFile.writeline "******* (Single-Valued Attributes) *******"
strwhenCreated = objItem.Get("whenCreated")
objOutputFile.writeline "whenCreated: " & strwhenCreated
strwhenChanged = objItem.Get("whenChanged")
objOutputFile.writeline "whenChanged: " & strwhenChanged
objItem.GetInfoEx Array("canonicalName"), 0
msgbox "done"
Thanks alot, any help would be appreciated!!

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic