Experts Exchange connects you with the people and services you need so you can get back to work.
Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.
'Constants for the Name Translate Object
Const ADS_NAME_INITTYPE_GC = 3
Const ADS_NAME_TYPE_NT4 = 3
Const ADS_NAME_TYPE_1779 = 1
'NetBIOS domain name for your AD
strNetBIOSDomain = "MYDOMAIN" 'Enter NETBIOS DomainName
'Get username and phone number
strNTName = InputBox("Enter user logon ID:", "Change User Phone Number")
strNewTele = InputBox("Enter the new phone number for " & strNTName,"New Number")
' Use the NameTranslate object to convert the NT user name to the
' Distinguished Name required for the LDAP provider.
Set objTrans = CreateObject("NameTranslate")
' Initialize NameTranslate by locating the Global Catalog.
objTrans.Init ADS_NAME_INITTYPE_GC, ""
' Use the Set method to specify the NT format of the object name.
objTrans.Set ADS_NAME_TYPE_NT4, strNetBIOSDomain & "\" & strNTName
' Use the Get method to retrieve the RPC 1779 Distinguished Name.
strUserDN = objTrans.Get(ADS_NAME_TYPE_1779)
'Bind to the AD user object
Set objUser = GetObject("LDAP://" & strUserDN)
WScript.Echo "Found user, number is currently: " & objUser.telephoneNumber
'If error, exit
If err.Number <> 0 Then
WScript.Echo "Error connecting to: " & strUserDN
'Change the phone number
objUser.telephoneNumber = strNewTele
If err.Number = 0 Then
WScript.Echo "Fail. Error code: " & err.Number
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.