Thursday, November 27, 2008

Retrieving User Telephone Properties

Retrieves user account attributes found on the Telephones 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
 
strHomePhone = objUser.Get("homePhone")
strPager = objUser.Get("pager")
strMobile = objUser.Get("mobile")
strIpPhone = objUser.Get("ipPhone")
strInfo = objUser.Get("info")
strFacsimileTelephoneNumber = _
  objUser.Get("facsimileTelephoneNumber")
 
strOtherHomePhone = objUser.GetEx("otherHomePhone")
strOtherPager = objUser.GetEx("otherPager")
strOtherMobile = objUser.GetEx("otherMobile")
strOtherIpPhone = objUser.GetEx("otherIpPhone")
strOtherFacsimileTelephoneNumber = _
  objUser.GetEx("otherFacsimileTelephoneNumber")
 
WScript.echo "homePhone: " & strHomePhone
WScript.echo "pager: " & strPager
WScript.echo "mobile: " & strMobile
WScript.echo "ipPhone: " & strIpPhone
WScript.echo "info: " & strInfo
WScript.echo "facsimileTelephoneNumber: " & _
 strFacsimileTelephoneNumber
 
For Each strValue in strOtherHomePhone
  WScript.echo "otherHomePhone: " & strValue
Next
For Each strValue in strOtherPager
  WScript.echo "otherPager: " & strValue
Next
For Each strValue in strOtherMobile
  WScript.echo "otherMobile: " & strValue
Next
For Each strValue in strOtherIpPhone
  WScript.echo "otherIpPhone: " & strValue
Next
For Each strValue in strOtherFacsimileTelephoneNumber
  WScript.echo "otherFacsimileTelephoneNumber: " & strValue
Next

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