keybrdcowboy
IS-IT--Management
I have been working on this for hours, and just don't know why it won't work. Keeps failing on the command.execut part, which tells me my search part is wrong. Just says there was a problem. Can anyone help? Thanks.
Option Explicit
Dim strFirstName, strLastName, strOfficeSymbol, strOrg, strTelNum, strEmailAdd, strStreetAdd, strCityAdd, strStateAdd, strZipAdd, strTitle
Dim strBofS, strUserName, objConnection, objCommand, objRecordSet, objRootDSE, strADsPath, objDomain
strUserName = InputBox("Please pick a username to find:")
fncCheckUserExist()
Function fncCheckUserExist()
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext")
Set objDomain = GetObject(strADsPath)
wscript.echo strADsPath
Set objConnection = CreateObject("ADODB.Connection")
objconnection.provider = "ADsDSOObject"
objConnection.Open
'"Provider=ADsDSOObject"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strADsPath & ";(&(objectClass=user)(Full Name=mobleyj));sAMAccountName;subtree"
' "(sAMAccountName=" & strUserName & "));" & "sAMAccountName, distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount = 0 Then
strUserName = strUserName
Else
While Not objRecordset.EOF
strUserName = "none"
Wend
End If
End Function
If strUserName = "none" Then
Wscript.echo "That username is already in use; please choose another!"
strUserName = InputBox("Please choose a different username; Must be unique")
fncCheckUserExist()
Else
wscript.echo "Username Found!!"
wscript.Exit
End If
Option Explicit
Dim strFirstName, strLastName, strOfficeSymbol, strOrg, strTelNum, strEmailAdd, strStreetAdd, strCityAdd, strStateAdd, strZipAdd, strTitle
Dim strBofS, strUserName, objConnection, objCommand, objRecordSet, objRootDSE, strADsPath, objDomain
strUserName = InputBox("Please pick a username to find:")
fncCheckUserExist()
Function fncCheckUserExist()
Set objRootDSE = GetObject("LDAP://rootDSE")
strADsPath = "LDAP://" & objRootDSE.Get("defaultNamingContext")
Set objDomain = GetObject(strADsPath)
wscript.echo strADsPath
Set objConnection = CreateObject("ADODB.Connection")
objconnection.provider = "ADsDSOObject"
objConnection.Open
'"Provider=ADsDSOObject"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = strADsPath & ";(&(objectClass=user)(Full Name=mobleyj));sAMAccountName;subtree"
' "(sAMAccountName=" & strUserName & "));" & "sAMAccountName, distinguishedName;subtree"
Set objRecordSet = objCommand.Execute
If objRecordSet.RecordCount = 0 Then
strUserName = strUserName
Else
While Not objRecordset.EOF
strUserName = "none"
Wend
End If
End Function
If strUserName = "none" Then
Wscript.echo "That username is already in use; please choose another!"
strUserName = InputBox("Please choose a different username; Must be unique")
fncCheckUserExist()
Else
wscript.echo "Username Found!!"
wscript.Exit
End If