I'm using Windows Script Host and VBScript to query LDAP. I'm running the
script from a local account that is not logged into the domain. I'm getting
an error "Provider: Permission denied". I have to be able to run the code
from a machine/account that is not in the domain (i.e.: local account on
machine not joined to the domain). Any assistance would be greatly
appreciated!
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Begin Code
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Option Explicit
'Declare variables
Dim stUser, stPass, oConnect, oCommand, oRecordSet
'Set variables
stUser = "domain\userid"
stPass = "password"
Set oConnect = CreateObject("ADODB.Connection")
oConnect.Provider = "ADsDSOObject"
oConnect.Properties("User ID") = stUser
oConnect.Properties("Password") = stPass
oConnect.Properties("Encrypt Password") = True
oConnect.Open stUser, stPass
WScript.Echo Err.Number 'This comes back as 0
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnect
WScript.Echo Err.Number 'This comes back as 0
oCommand.CommandText = _
"<LDAP://domain/DC=xx,DC=xx,DC=com>;;name;subtree"
'NOTE: in the line above, I have to specify the domain or the code will
return the error "Provider: Table does not exist."
'Here is where the error occurs
Set oRecordSet = oCommand.Execute
script from a local account that is not logged into the domain. I'm getting
an error "Provider: Permission denied". I have to be able to run the code
from a machine/account that is not in the domain (i.e.: local account on
machine not joined to the domain). Any assistance would be greatly
appreciated!
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Begin Code
'-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Option Explicit
'Declare variables
Dim stUser, stPass, oConnect, oCommand, oRecordSet
'Set variables
stUser = "domain\userid"
stPass = "password"
Set oConnect = CreateObject("ADODB.Connection")
oConnect.Provider = "ADsDSOObject"
oConnect.Properties("User ID") = stUser
oConnect.Properties("Password") = stPass
oConnect.Properties("Encrypt Password") = True
oConnect.Open stUser, stPass
WScript.Echo Err.Number 'This comes back as 0
Set oCommand = CreateObject("ADODB.Command")
oCommand.ActiveConnection = oConnect
WScript.Echo Err.Number 'This comes back as 0
oCommand.CommandText = _
"<LDAP://domain/DC=xx,DC=xx,DC=com>;;name;subtree"
'NOTE: in the line above, I have to specify the domain or the code will
return the error "Provider: Table does not exist."
'Here is where the error occurs
Set oRecordSet = oCommand.Execute