?
Solved

Connecting to DC and Change settings

Posted on 2011-04-27
2
Medium Priority
?
345 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,

0
Comment
Question by:Neo_78
2 Comments
 
LVL 12

Accepted Solution

by:
prashanthd earned 2000 total points
ID: 35473721
Try the following
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 LCase(Location) = lcase("Location1") Then
    Set objUser =GetObject("LDAP://DC1/CN=User1,OU=OU1,DC=Domain,DC=Com")
    objUser.Put "userWorkstations", vInput
    objUser.SetInfo
ElseIf LCase(Location) = lcase("Location2") Then
    Set ObjUser=GetObject("LDAP://DC2/CN=User1,OU=OU1,DC=Domain,DC=Com"")
    objUser.Put "userWorkstations", vInput
    objUser.SetInfo
End If

Open in new window

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 35474411
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

0

Featured Post

Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here's a look at newsworthy articles and community happenings during the last month.
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question