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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bizarre LDAP Issue

Status
Not open for further replies.

GnDn

MIS
Sep 2, 2010
2
US
Alright I've been banging my head against the wall for three days on this one, and was hoping someone might have some insight on what could be causing this. I've written several multi-threaded vbscripts in the past to pull various information from multiple domains. However I'm now experiencing an issue I can't seem to solve. I've been querying LDAP to get a list of machines to work with, and it's worked fine for several scripts in the past, and is still working right now, but for what ever reason when I try to dissect the code it will not work on 3 out of the 10 domains I try it on. Here's the code I'm using to connect:


Const conUser = "aaa\user"
Const conPass = "pass"
strDomainName = "aaa.domain.com"

Dim objConnection, objCommand
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = conUser
objConnection.Properties("Password") = conPass
objConnection.Properties("Encrypt Password") = True
objConnection.Properties("ADSI Flag") = 3
objConnection.Open "Active Directory Provider"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 90000
objCommand.Properties("Timeout") = 30
objCommand.Properties("Searchscope") = 2
objCommand.Properties("Cache Results") = False
objCommand.CommandText = "SELECT ADsPath, pwdLastSet " &_
"FROM 'LDAP://" & strDomainName & "' " &_
"WHERE objectClass='computer'"
WScript.Echo "before execute"
Set objRecordSet = objCommand.Execute
WScript.Echo "after execute"


This code is rather simple and straight forward, all I'm trying to do is load all the entries into a recordset for the "aaa.domain.com" domain. When this works I receive both echo strings, but when it doesn't I receive the following message:

before execute
C:\test.vbs(24, 1) Provider: Table does not exist.

I am almost convinced it has nothing to do with the code and something else is causing this to not work, but I've tried everything I can think of. As I said this is already working on a few other scripts so I've tried it from the servers it's already working on, I've tried from other computers, but still can't pinpoint it, Please Help!
 
I've posted this question on a few sites and found the answer I was looking for but wanted to post it here just in case it helps anyone else. This was resolved by adding the following lines of code:

Const ADS_SECURE_AUTHENTICATION = &H1
Const ADS_SERVER_BIND = &H200

objConnection.Properties("ADSI Flag") = ADS_SERVER_BIND Or ADS_SECURE_AUTHENTICATION

I'm not 100% sure why this worked, but my suspicion is that the trust rights between some of the domains are a little different.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top