Thursday, November 27, 2008

Reading Address Page Information for a User Account

Returns address-related attribute values for the MyerKen Active Directory user account.

On Error Resume Next
Set objUser = GetObject _
    ("LDAP://cn=MyerKen,ou=Management,dc=NA,dc=fabrikam,dc=com")
 
strStreetAddress = objUser.Get("streetAddress")
strLocalityName = objUser.Get("l")
strStreetName = objUser.Get("st")
strPostalCode = objUser.Get("postalCode")
strCountryName = objUser.Get("c")
arrPostOfficeBox = objUser.GetEx("postOfficeBox")
 
WScript.echo "Street Address: " & strStreetAddress
WScript.echo "Locality: " & strLocalityName
WScript.echo "Street: " & strStreetName
WScript.echo "Postal Code: " & strPostalCode
WScript.echo "Country: " & strCountryName
 
WScript.echo "Post Office Boxes:"
For Each strValue in arrPostOfficeBox
    WScript.echo vbTab & vbTab & strValue
Next

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