If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > ADO/LDAP query gives "Table does not exist" error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-07, 19:24
sergei77 sergei77 is offline
Registered User
 
Join Date: Aug 2007
Posts: 3
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
%>
Reply With Quote
  #2 (permalink)  
Old 08-19-07, 17:22
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 08-20-07, 09:12
sergei77 sergei77 is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 08-20-07, 09:42
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #5 (permalink)  
Old 08-20-07, 11:19
sergei77 sergei77 is offline
Registered User
 
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 11:22.
Reply With Quote
  #6 (permalink)  
Old 01-14-08, 05:44
schabe schabe is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On