• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

VB Script - LDAP question

My code errors out saying "One or more errors occurred during processing of command."  Source provider
set adorecordset = adoconnection.execute ("ldap://MyLdapServer.MyInternalDomain.MyExternalDomain.com:389/OU=MyUsers,DC=MyInternalDomain,DC=MyExternalDomain,DC=com")

''''''''''''''''''''''''''''''''''''Entire code
Dim adoConnection
Dim adoRecordset
Dim str

set adoConnection = CreateObject ("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "", "CN=MyInternalDomain/administrator,CN=Users,DC=MyInternalDomain,dc=MyExternalDomain,dc=com", "dinglberry"
set adorecordset = adoconnection.execute ("ldap://MyLdapServer.MyInternalDomain.MyExternalDomain.com:389/OU=RELTDUsers,DC=MyInternalDomain,DC=MyExternalDomain,DC=com")
adoconnection.close
Set adoRecordset = Nothing

0
DSaldanaRELTD2
Asked:
DSaldanaRELTD2
1 Solution
 
NopiusCommented:
I'm not a master in VB, but have some experience with LDAP search filters. If you are shure that connection is established,  try another syntax:
set adorecordset = adoconnection.execute ("(objectclass=*)")
0
 
gabesoCommented:
Shouldn't it be:

CN=administrator,CN=Users,DC=MyInternalDomain,dc=MyExternalDomain,dc=com

0
 
tone28Commented:
You are missing a whole bunch of stuff. Just replace the servername, ou structure and don't search for the administrator userid. I just put that because you referenced it above. If you have the rights to do that then fine.

---------------------

Dim adoConnection
Dim adoRecordset
Dim str

set adoConnection = CreateObject ("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "Active Directory Provider"

Dim Base
Dim Filter
Dim Attributes
Dim Level

Base = "<LDAP://MyLdapServer/OU=RELTDUsers,DC=MyInternalDomain,DC=MyExternalDomain,DC=com>;"
' You may not have the rights to display the administrator account. Choose another userid

Filter = "(&(objectClass=user)(objectCategory=person)(samAccountName=Administrator));"
Attributes = "displayName;"
Level = "SubTree"

set adorecordset = adoconnection.execute (Base & Filter & Attributes & Level)

adorecordset.MoveFirst
While Not adorecordset.EOF
    Wscript.echo adorecordset.Fields(0).Value & vbCrLf
    adorecordset.MoveNext
Wend
adoconnection.close
Set adoRecordset = Nothing
0
 
DSaldanaRELTD2Author Commented:
tone28 could you recommend a book on this subject?  The code above was great and worked pretty much right out of the gate.

What we are trying to do is authenticate a username and password.
0
 
tone28Commented:
If you are in a domain then the code will use your credentials. There are options to add a username and password if you need to do some automated process id type work. Also there are options to encrypt passwords sent.

For books I would recommend Robbie Allen.

http://www.rallenhome.com/books/adcookbook/toc.html

and

http://rallenhome.com/books/winsckbk/toc.html

He is a great author and even has example on his website. I would warn though use his examples to learn how to do it rather than any cut and paste jobs. Let me know if you have any more specific questions. I would be happy to help.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now