In tip 9680 » How can a script return user properties using the WinNT provider, we returned selected user properties.

You can use the LDAP provider to return Active Directory user attributes.

UserAttr.vbs is a sample script that displays some user attributes.

The syntax for using the UserAttr.vbs is:

CScript.exe //nologo <Drive:>\<FolderName>\UserAttr.vbs <distinguishedName>


cscript //nologo c:\util\UserAttr.vbs "CN=Jerold Schulman,CN=Users,DC=JSIINC,DC=COM"                              cscript //nologo c:\util\UserAttr.vbs "CN=Test User,OU=OU_TEST,DC=JSIINC,DC=COM"
UserAttr.vbs contains:
Dim objArguments, strDomainUser                              Set objArguments = Wscript.Arguments                              If WScript.Arguments.Count = 0 then Wscript.Quit                              strDomainUser=objArguments(0)                              On Error Resume Next                              WScript.Echo "DN: " & strDomainUser                              Set objUser = GetObject("LDAP://" & strDomainUser)                              WScript.Echo "Street Address: " & objUser.streetAddress                              WScript.Echo "Locality: " & objUser.l                              WScript.Echo "State/province: " &                              WScript.Echo "Postal Code: " & objUser.postalCode                              WScript.Echo "Country: " & objUser.c