Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2007
    Posts
    3

    Unanswered: ADO/LDAP query gives "Table does not exist" error

    I am trying to retrieve data about a user using an ADO/LDAP query from my ASP page (classic ASP, not ASP .NET). I am connecting to an Active Directory server over LDAP on port 636 (SSL). However I get a "Table does not exist." error. The credentials and connection details I am using are correct as I have tried connecting using an LDAP client and it works fine, but my code in ASP it fails. I have tried many permutations of the code and I aways get the same error! The Web server and LDAP server are at different locations and on different domains.

    Here is the code (sensitive details replaced with X's):

    <%
    Option Explicit

    Dim ADsPath
    Dim cn
    Dim com
    Dim rs

    ' Set the path

    ADsPath = "LDAP://XXX.XXX.XXX.XXX:636/OU=Users,OU=XXXX,DC=XXXX,DC=XXXX,DC=XXX"

    Set cn = CreateObject("ADODB.Connection")
    cn.Provider = "ADsDSOObject"
    cn.Properties("User ID") = "uid=XXXX,OU=Users,OU=XXXX,DC=XXXX,DC=XXXX,DC= XXX"
    cn.Properties("Password") = "XXXX"

    ' Set flag indicating SSL
    cn.Properties("ADSI Flag") = 34

    cn.Open "ADSI"

    Set com = CreateObject("ADODB.Command")
    Set com.ActiveConnection = cn

    ' Open recordset

    com.CommandText = "<" & ADsPath & ">;(CN=XXXX);givenName,sn,mail;base"
    Set rs = com.Execute ' *** CAUSES ERROR ***

    If Not rs.EOF Then
    Response.Write rs("givenName") & " " & rs("sn") & " - " & rs("mail")
    End If

    rs.Close
    Set rs = Nothing
    %>

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    com.CommandText = "<" & ADsPath & ">;(CN=XXXX);givenName,sn,mail;base"
    I don't believe you want to use the semi colons...
    Have a read of this technet article on how to use LDAP and let us know how you get on
    George
    Home | Blog

  3. #3
    Join Date
    Aug 2007
    Posts
    3
    Semicolons are not the problem. According to Microsoft documentation you need to separate the four parameters (server, filter, DN and base) with a semicolon when doing this programmatically as I am:

    http://support.microsoft.com/kb/q187529/

    I think the problem is something to do with security/SSL/the fact that the servers are not in the same domain. However I am able to connect using an LDAP client tool so the two servers are able to connect, but there is probably something that ADO doesn't like, the moodly little thing that it is.

    The annoying thing is that LDAP through ADO seems to always return just one generic error "table does not exist" no matter what the problem is. Which of course is of no help whatsoever

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You are right, my bad!
    the link that you posted suggests a different method to the one you're using
    Code:
      Dim conn As ADODB.Connection
          Dim rs As ADODB.Recordset
    
          Set conn = New ADODB.Connection
          conn.Provider = "ADSDSOObject"
          conn.Open "ADs Provider"
    
          Set rs = conn.Execute( _ 
                "<LDAP://server/o=organization/ou=site/cn=recipients>;" _
                & "(objectClass=*);ADsPath,objectClass,cn;subtree")
    
          While Not rs.EOF
             Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, _
                   rs.Fields(2).Value
             rs.MoveNext
          Wend
    
          conn.Close
    Have you tried this?
    George
    Home | Blog

  5. #5
    Join Date
    Aug 2007
    Posts
    3
    Yes I have, the only difference is that they are executing the statement directly from the connection instead of doing it through a command object.

    There are also two ways to connect, one through ADO and the other through ADSI, both fail in the same way, different errors but probably same reason, using the second method it's also a generic error.
    Last edited by sergei77; 08-20-07 at 12:22.

  6. #6
    Join Date
    Jan 2008
    Posts
    1

    LDAP connexion

    Hello,

    I have the same problem as you when I try to execute the ldap request. Did you fond any information ?

    Thanks in advance for your answer


    Sylvie

Posting Permissions

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