Thursday, November 27, 2008

Retrieving Telephone Settings for a User Account

Displays all the telephone 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")
 
strHomePhone = objUser.Get("homePhone")
strPager = objUser.Get("pager")
strMobile = objUser.Get("mobile")
strIpPhone = objUser.Get("ipPhone")
strInfo = objUser.Get("info")
strFacsimileTelephoneNumber = objUser.Get("facsimileTelephoneNumber")
 
arrOtherHomePhone = objUser.GetEx("otherHomePhone")
arrOtherPager = objUser.GetEx("otherPager")
arrOtherMobile = objUser.GetEx("otherMobile")
arrOtherIpPhone = objUser.GetEx("otherIpPhone")
arrOtherFacsimileTelephoneNumber = _
    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
 
WScript.Echo "otherHomePhone:"
For Each strValue in arrOtherHomePhone
    WScript.Echo strValue
Next
 
WScript.Echo "otherPager:"
For Each strValue in arrOtherPager
    WScript.Echo strValue
Next
 
WScript.Echo "otherMobile:"
For Each strValue in arrOtherMobile
    WScript.Echo strValue
Next
 
WScript.Echo "otherIpPhone:"
For Each strValue in arrOtherIpPhone
    WScript.Echo strValue
Next
 
WScript.Echo "otherFacsimileTelephoneNumber:"
For Each strValue in arrOtherFacsimileTelephoneNumber
    WScript.Echo strValue
Next

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