JSI Tip 9690. How can a script return user properties using the LDAP provider?

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
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: " & objUser.st
WScript.Echo "Postal Code: " & objUser.postalCode
WScript.Echo "Country: " & objUser.c

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.