Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

LDAP query from ODBC?

 
   Database Help (Home) -> Visual Basic -> ODBC RSS
Next:  Access report linked to a word document produces ..  
Author Message
oaksong

External


Since: Jun 28, 2007
Posts: 2



(Msg. 1) Posted: Thu Jun 28, 2007 2:41 pm
Post subject: LDAP query from ODBC?
Archived from groups: microsoft>public>vb>database>odbc (more info?)

I'm trying to build a query to pull some information from my LDAP
based on a user ID.

Dim conLDAP As ADODB.Connection
Dim strSQL As String
Dim strLDAPConn As String
Dim rsUser As ADODB.Recordset
Set conLDAP = New ADODB.Connection
conLDAP.Provider = "ADSDSOOBject"
strSQL = "SELECT givenName, sn FROM LDAP://" & gstrLDAPURL & "
where sAMAccountName = '" & strUserName & "'"
conLDAP.Provider = "ADsDSOObject"
'open connection
conLDAP.Open "DSQuery"
'execute LDAP query
err.Clear
Set rsUser = conLDAP.Execute(strSQL)

I'm getting an error 2147217900, "One or more errors occurred during
processing of command."

gstrLDAPURL is a string of dc='s items, ie. dc=po1,dc=po2,dc=etc.

Any suggestions??

 >> Stay informed about: LDAP query from ODBC? 
Back to top
Login to vote
oaksong

External


Since: Jun 28, 2007
Posts: 2



(Msg. 2) Posted: Fri Jun 29, 2007 12:49 pm
Post subject: Re: LDAP query from ODBC? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Jun 28, 3:41 pm, oaksong wrote:
> I'm trying to build a query to pull some information from my LDAP
> based on a user ID.
>
> Dim conLDAP As ADODB.Connection
> Dim strSQL As String
> Dim strLDAPConn As String
> Dim rsUser As ADODB.Recordset
> Set conLDAP = New ADODB.Connection
> conLDAP.Provider = "ADSDSOOBject"
> strSQL = "SELECT givenName, sn FROM LDAP://" & gstrLDAPURL & "
> where sAMAccountName = '" & strUserName & "'"
> conLDAP.Provider = "ADsDSOObject"
> 'open connection
> conLDAP.Open "DSQuery"
> 'execute LDAP query
> err.Clear
> Set rsUser = conLDAP.Execute(strSQL)
>
> I'm getting an error 2147217900, "One or more errors occurred during
> processing of command."
>
> gstrLDAPURL is a string of dc='s items, ie. dc=po1,dc=po2,dc=etc.
>
> Any suggestions??

I've simplified this quite a bit....
---------------------------------------------------------------------------------------------------------------------
objConn.Open "Provider=ADsDSOObject;"
objComm.ActiveConnection = objConn
If InStr(UCase(dom), "AA") > 0 Then
dom = "dc=" & dom & ",dc=dvx,"
ElseIf InStr(UCase(dom), "V") > 0 Then
dom = "dc=" & dom & ",dc=mex,"
End If

ldStr = "<LDAP://" & dom & "dc=vx,dc=com>;" _
& "(&(objectCategory=person)(objectClass=user)
(sAMAccountName=" & strUserName & "));name, sAMAccountName;subtree"
objComm.CommandText = ldStr
'(sAMAccountName=" & strUserName & ")
Set ObjRS = objComm.Execute

While Not ObjRS.EOF
MsgBox ObjRS.Fields("name") & ": " &
ObjRS.Fields("sAMAccountName").value & " is valid."
ObjRS.MoveNext
Wend

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

In one instance it works as it should. In that instance the dom value
includes a local server. In the other instance the dom contains a
remote server.

Using the MMC plugin, Active Directory Users and Computers, I can
'connect' to the remote server, create a query, and get the
appropriate result. However trying essentially the same thing at my
workstation yields no error and no result.

I'm fairly stymied at this point as to what might be happening
remotely, and why the MMC produces a result while the application does
not.

 >> Stay informed about: LDAP query from ODBC? 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
The whole ODBC idea - To date my database stuff is with access databases, and I have no real appreciation with using ODBC. My VB6 application: Developing code to be run on a Win2000 machine that needs to read/write certain records in a Foxpro database. However the ..

ODBC Access reference material - Hi there, I was wondering if there was some kind of online reference as the the syntax used for a Microsoft ODBC Access driver's SQL statements. I'm converting a web site over to another server and I'm having syntax issues as I've just switched....

ODBC CONNECTION FROM COMMAND LINE - I am trying to get an ODBC connection created from a commandline, I have created the ODBC connection, exported the registry key, and have tried doing regedit /s "regkey", problem is after I do that it never shows us in the ODBC manager, it sh...

Automate ODBC DSN Setup - I have been thinking of using VBscript to automate the set up of the ODBC DSN entries. There are some discussions on the Internet that I can find. Unfortunately, none of them gives me any hints on how I can store the username (such as sa) and passwor...

Cursor Error w/ ODBC SQL2000 - My office inherited a legacy VB6 program that connects via a MSRDC to a SQL2000 server. The original ODBC connection pointed to a legacy Win2000 Adv Server w/ SQL2k, we have upgraded a test server Win2k3 w/ the same SQL2k. The previous server didn't..
   Database Help (Home) -> Visual Basic -> ODBC All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]