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_SUBTR EE = 2
strUSER = InputBox("Pleas e 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("A DODB.Connection ")
Set objCommand = CreateObject("A DODB.Command")
objConnection.P rovider = ("ADsDSOObject" )
objConnection.O pen "Active Directory Provider"
objCommand.Acti veConnection = objConnection
objUser = GetObject ("'LDAP://OU=xx,dc=xx,dc= xx,dc=xx'" & obj.User.UserNa me)
objCommand.Comm andText = "SELECT samAccountName FROM " & _
"'LDAP://OU=xx,dc=xx,dc= xx,dc=xx'" & _
"WHERE samAccountName = %strUser%"
objCommand.Prop erties("SearchS cope") = ADS_SCOPE_SUBTR EE
Set objRecordSet = objCommand.Exec ute
If objRecordSet.Re cordCount = 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
Thank you -
On Error Resume Next
Const ADS_SCOPE_SUBTR EE = 2
strUSER = InputBox("Pleas e 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("A DODB.Connection ")
Set objCommand = CreateObject("A DODB.Command")
objConnection.P rovider = ("ADsDSOObject" )
objConnection.O pen "Active Directory Provider"
objCommand.Acti veConnection = objConnection
objUser = GetObject ("'LDAP://OU=xx,dc=xx,dc= xx,dc=xx'" & obj.User.UserNa me)
objCommand.Comm andText = "SELECT samAccountName FROM " & _
"'LDAP://OU=xx,dc=xx,dc= xx,dc=xx'" & _
"WHERE samAccountName = %strUser%"
objCommand.Prop erties("SearchS cope") = ADS_SCOPE_SUBTR EE
Set objRecordSet = objCommand.Exec ute
If objRecordSet.Re cordCount = 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
Comment