Results 1 to 3 of 3

Thread: Query LDAP using ADO

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Query LDAP using ADO

    I have an application that takes an LDAP search string including the uid and then returns the common name as a string. It works fine, but unfortunately after about 3500 uses in a loop it starts to fail with "Table does not exist" (as in the connection details are incorrect) for a while and then it recovers and starts working again. The loop goes something like this:

    VB Code:
    1. ' Set up the ADODB.Connection object and call the .Open method
    2. oLDAP.Connect
    3.  
    4. While not EOF
    5.   ' GetCN uses oRecordSet = oConnection.Execute("SELECT cn FROM.... ")
    6.   ' to either return the cn string or return "*NULL TRACE*" and report reason
    7.   ' to the debug window
    8.   sSomething = oLDAP.GetCN("uid=blah,o=glah,ou=etc,dc=etc")
    9. Wend
    10.  
    11. oLDAP.Disconnect ' closes the ADODB.Connection

    I can't understand why it works inconsistently as the connection details do not change, however Ethereal (packet sniffer) shows that the connection is opened and closed on each iteration, where I would have thought that the connection would stay open until specifically closed (i.e. outside the loop). So I figure I'm either using ADO incorrectly or I'm hammering the LDAP connection pool until it runs out (LDAP connection is remote).

    I would be grateful for any clues?
    Last edited by Moik; Apr 21st, 2006 at 03:38 AM.

  2. #2
    eltiT resU motsuC Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Query LDAP using ADO

    Welcome!

    why not open a recordset and loop thru it. that will stay "open" until your done? (i've never used an LDAP so im not sure the reason for it)

    VB Code:
    1. Dim Rs as New Recordset
    2. Rs.Open "SELECT .....",oConnection
    3. Do while not Rs.EOF
    4.  
    5.     ......
    6.     Rs.MoveNext
    7. Loop
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    4

    Re: Query LDAP using ADO

    Thanks for the response.

    Part of the problem may well be the way I'm using it because all the examples I've found show many records being pulled back and then going through the recordset as you suggest. Unfortunately I only want to match one uid.

    I'm pulling a recordset out of an SQL database and one of the fields is an LDAP search string, so I am looping through the SQL recordset and in each case finding the cn from the LDAP using the search string and then writing it in a human readable form to a csv file.

    Further testing has shown that it fails with reasonable consistency after about 3965 LDAP accesses. Seperate testing using a Perl script to access the LDAP didn't fail even after 100,000 accesses so I'm beginnning to suspect the ADO as being the problem. I have had better success by inserting a number of Sleep statements into the code.

    Does anyone know how to connect to LDAP using RDO? In the mean time I'm going to try catching the failure and then waiting 10 milliseconds before trying again to see if it can recover (since Ethereal says it takes just over 5 ms to complete an LDAP access).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width