LDAP query
Hi,
I need to perform a query (LDAP) against ADS.
I want to search for a user in ADS and retrieve some information about this
user from ADS-attributes.
I use the following VBS code, bascially this code works, however it seems
that I can only to a LDAP-search for a user using the DisplayName (?)
Currently I use the following command:
GetObject("LDAP://cn=Joe-Developer,cn=Users," &
objRootDSE.Get("defaultNamingContext"))
OK.. this works, but what I need is to search for the "samUserAccount", or
FQ-name - so I tried something like this:
GetObject("LDAP://cn=User001,cn=Users," &
objRootDSE.Get("defaultNamingContext"))
and
GetObject("LDAP://cn=domain.com/Users/User001,cn=Users," &
objRootDSE.Get("defaultNamingContext"))
Doesnt work.
How could I do a query that seaches for samUserAccount ?
Thank you
'***
Set objRootDSE = GetObject("LDAP://rootDSE")
Set objUser = GetObject("LDAP://cn=Joe-Developer,cn=Users," &
objRootDSE.Get("defaultNamingContext"))
strDisplayName = objUser.Get("displayName")
strMail = objUser.Get("Mail")
strDescription = objUser.Get("Description")
Dep = objUser.Department
Company = objUser.Company
Tel = objUser.Telephonenumber
account = objUser.SamAccountname
Wscript.Echo "Account : " & Account
Wscript.Echo "displayName: " & strDisplayName
Wscript.Echo "Mail : " & strMail
Wscript.Echo "Description: " & strDescription
Wscript.Echo "Department : " & Dep
Wscript.Echo "Company : " & Company
Wscript.Echo "Tel : " & Tel
|