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")
Set adoRecordset = Nothing

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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=*)")
gabesoSolution ArchitectCommented:
Shouldn't it be:


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)

While Not adorecordset.EOF
    Wscript.echo adorecordset.Fields(0).Value & vbCrLf
Set adoRecordset = Nothing

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
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.




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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.