[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
'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
Administration of Active Directory does not have to be hard. Too often what should be a simple task is made more difficult than it needs to be.The solution? Hyena from SystemTools Software. With ease-of-use as well as powerful importing and bulk updating capabilities.
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.