Thursday, November 27, 2008

Retrieving User Account Address Attributes

Retrieves user account attributes found on the Address 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
 
strStreetAddress = objUser.Get("streetAddress")
strPostOfficeBox = objUser.Get("postOfficeBox")
strLocalityName = objUser.Get("l")
strStreetName = objUser.Get("st")
strPostalCode = objUser.Get("postalCode")
strCountryName = objUser.Get("c")
 
WScript.Echo "streetAddress: " & strStreetAddress
WScript.Echo "postOfficeBox: " & strPostOfficeBox
WScript.Echo "l: " & strLocalityName
WScript.Echo "st: " & strStreetName
WScript.Echo "postalCode: " & strPostalCode
WScript.Echo "c: " & strCountryName

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