Monday, December 1, 2008

Returning the General Properties of an OU

Returns information found on the General Properties page in Active Directory Users and Computers for an OU named Sales.

On Error Resume Next
Set objContainer = GetObject _
  ("LDAP://ou=Sales,dc=NA,dc=fabrikam,dc=com")
 
strStreetAddress = objContainer.Get("street")
strLocalityName = objContainer.Get("l")
strStreetName = objContainer.Get("st")
strPostalCode = objContainer.Get("postalCode")
strCountryName = objContainer.Get("c")
 
strDescription = objContainer.GetEx("description")
 
For Each strValue in strDescription
  WScript.echo "description: " & strValue
Next
 
WScript.echo "streetAddress: " & strStreetAddress
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