Trying to create a text box w/user input to enter a suggested user name and query AD to see if the name is available. This is for HR users who do not have access to the Admin tools to open the container. Can this be written another way to "prompt" for user input somewhere else in the script?
Thank you -
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
strUSER = InputBox("Please put the desired User Name:","USER")
If strUSER = "" Then
WScript.Echo "No User Name entered. Program aborted."
Wscript.Quit
End If
On Error Resume Next
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = ("ADsDSOObject")
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
objUser = GetObject ("'LDAP://OU=xx,dc=xx,dc=xx,dc=xx'" & obj.User.UserName)
objCommand.CommandText = "SELECT samAccountName FROM " & _
"'LDAP://OU=xx,dc=xx,dc=xx,dc=xx'" & _
"WHERE samAccountName = %strUser%"
objCommand.Properties("SearchScope") = ADS_SCOPE_SUBTREE
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount = 0 Then
Wscript.Echo "The Account name is not being used."
Else
Wscript.Echo "The Account name is being used. Please choose another name."
End If