We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

Connecting to DC and Change settings

Medium Priority
366 Views
Last Modified: 2012-05-11
We are trying to create a vbscript which will be used by helpdesk team to add the PC name to the Logon To tab of one user property. The challange is to connect to a Domain Controller based on location and do the changes so that user need not wait for replication. The below script is there which will do the same but only issue we are facing is that I want the user to specify the location in the input box and based on input the DC will be connected. When the user is providing the input for the location it is not able to recognise the same as whatever is written by User


============================================================
Const ADS_PROPERTY_UPDATE = 2
Dim vInput
vInput = InputBox("Enter a HostName","WorkStation")
Dim Location
Location = InputBox("Enter the Location","Location")
Wscript.echo LOcation
If Location =Location1 Then
Set objUser =GetObject("LDAP://DC1/CN=User1,OU=OU1,DC=Domain,DC=Com")
Elseif Location = Location2 Then
Set ObjUser=GetObject("LDAP://DC2/CN=User1,OU=OU1,DC=Domain,DC=Com"")
objUser.Put "userWorkstations", vInput
objUser.SetInfo
End if
============================================================

PLease suggest if we can do something for the same.

Thanks and Regards,

Comment
Watch Question

Top Expert 2011
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
CERTIFIED EXPERT
Top Expert 2007

Commented:
If it's merely a number on the DC, you can skip the if logic and shorten it a bit...
Const ADS_PROPERTY_UPDATE = 2
Dim vInput : vInput = InputBox("Enter a HostName","WorkStation")
Dim Location : Location = Right(InputBox("Enter the Location","Location"), 1)
Dim objUser : Set objUser =GetObject("LDAP://DC" & Location & "/CN=User1,OU=OU1,DC=Domain,DC=Com")
objUser.Put "userWorkstations", vInput
objUser.SetInfo

Open in new window

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.