Thursday, November 27, 2008

Retrieving Organization Information

Retrieves user account attributes found on the Organization page of the user account object in Active Directory Users and Computers.

On Error Resume Next
Set objUser = GetObject _
  ("LDAP://cn=myerken,ou=management,dc=fabrikam,dc=com")
objUser.GetInfo
 
strTitle = objUser.Get("title")
strDepartment = objUser.Get("department")
strCompany = objUser.Get("company")
strManager = objUser.Get("manager")
 
strDirectReports = _
  objUser.GetEx("directReports")
 
WScript.echo "title: " & strTitle
WScript.echo "department: " & strDepartment
WScript.echo "company: " & strCompany
WScript.echo "manager: " & strManager
 
For Each strValue in strDirectReports
  WScript.echo "directReports: " & strValue
Next

This is a VB Script, this can be used by saving the file in .vbs file