Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Provider: Permission denied

Status
Not open for further replies.

msacks

Programmer
Dec 18, 2003
2
US
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
 
I am doing the same thing, the only thing that works for me is to use:
Code:
runas /netonly /user:domain\userid "cscript script.vbs"
 
:)
Here's the solution:

Change the oConnect.Open line as follows:

oConnect.Open "Active Directory Provider", stUser, stPass
 
That still doens't work for me, does the sruser = "domain\userid" ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top