Thursday, November 27, 2008

Retrieving Organization Information for a User Account

Retrieves organization information (including a list of all direct reports) for the MyerKen user account in Active Directory.

 

On Error Resume Next
Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
 
strTitle = objUser.Get("title")
strDepartment = objUser.Get("department")
strCompany = objUser.Get("company")
strManager = objUser.Get("manager")
 
arrDirectReports = objUser.GetEx("directReports")
 
WScript.echo "Title: " & strTitle
WScript.echo "Department: " & strDepartment
WScript.echo "Company: " & strCompany
WScript.echo "Manager: " & strManager
 
WScript.echo "Direct Reports:"
For Each strValue in arrDirectReports
    WScript.echo strValue
Next

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