Link to home
Start Free TrialLog in
Avatar of GKnoll
GKnoll

asked on

Data Source=Active Directory Provider

What I want to do is this.
From a form in MS access, query LDAP to retrieve specific information, based on the a UserID.
I found this code floating around, and I am not sure if I am doing things right.
When I examine differant sets of code I see this:
conn.Open "Data Source=Active Directory Provider;Provider=ADsDSOObject"

Now my question is, what should I be putting between the quotes?
The code goes to it's error routine right after this liine:
Set rs = conn.Execute(sQuery)
which tells me either the sQuery variable is wrong or I am not getting a connection.

If you need to see more of or all the code I will be glad to post it. I am just not sure if I should post all the code here.

Any help would be great.

Thanks
Greg
Avatar of sirbounty
sirbounty
Flag of United States of America image

What are you looking to pull?

Set conn=CreateObject("ADODB.Connection")
Set cmd=CreateObject("ADODB.Command")
conn.Provider="ADsDSOObject"
conn.Open "Active Directory Provider"
cmd.ActiveConnection=conn
cmd.CommandText="Select sAMAccountName From 'LDAP://dc=somewhere,dc=com' Where objectCategory='user' And sAMAccountName='" & strUser & "'"
Set rs=cmd.Execute
If Not rs.Eof Then
  'reference rs.Fields(0).Value
End If
Hmm - for that to search though, you'll need:
Const SubTree_Scope=2

And add cmd properties of
cmd.Properties("SearchScope"=SubTree_Scope
after the activeconnection is established...
Avatar of GKnoll
GKnoll

ASKER

Set conn=CreateObject("ADODB.Connection")
Set cmd=CreateObject("ADODB.Command")
conn.Provider="ADsDSOObject"
conn.Open "Active Directory Provider"
cmd.ActiveConnection=conn
cmd.CommandText="Select sAMAccountName From 'LDAP://dc=somewhere,dc=com' Where objectCategory='user' And sAMAccountName='" & strUser & "'"
Set rs=cmd.Execute
If Not rs.Eof Then
  'reference rs.Fields(0).Value
End If

What I need to know is in the line ==>conn.Open<== am I supposed to have "Active Directory Provider" these words exactly, or am I supposed to put in the informaion to my active directoy provider.
Further, the active directory provider is what? the server it self? ie: mail.company.com?

I am sorry but this LDAP stuf makes me crazy.

Greg
ASKER CERTIFIED SOLUTION
Avatar of sirbounty
sirbounty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What was missing?
Just curious why the "B" grade?
Avatar of GKnoll

ASKER

I understand what I need for the LDAP Info. I gues I am just confused about what specificly follows

conn.open ??????????????

It just doesn't seem to make sense to have the string "Active Directory Provider". Is that how the provider is referenced with the ADsDSOObject ??? If so thats ok. Then my problem is either in the query string or the LDAP info I am using is not quite right.

Thank you for all your help.

I think maybe I just need to study this whole thing some more.