Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OLE/ADO ADSI interface to iPlanet LDAP

42 views
Skip to first unread message

Jeff Allen

unread,
Dec 6, 2001, 2:48:57 PM12/6/01
to
I am having issues with using OLE/ADO ADSI interface, via VB6, to an iPlanet
LDAP server. I know I am making a proper connection, because I can use the
same connection parameters, login via IADs interface, make a connection to
an individual object and retrieve objects and properties. Unfortunately,
IADs interface will not allow me to query, only enumerate through the entire
user collection (BLECH!). Also, I'm not receiving "Table does not exist"
errors.

The two errors I am receiving are:

Provider (0x80040E14)
One or more errors occurred during processing of command.

and

Active Directory (0x80040E37)
One or more arguments are invalid

I have not been able to find reference to either of these error codes in any
documentation I can find, and they aren't helping me at all. I've tried to
investigate other interfaces, but the only other one used in the company is
PerLDAP and I'm hoping I don't have to try to incorporate yet another
language and interface.

I'm using an ActiveX DLL COM object to manage my connections and data
retrieval. My code is as follows (Command object implementation, 'uid' is a
custom attribute in the target LDAP directory):

Const conLDAPUserID = "uid=user,ou=specialusers,o=blah.com"
Const conLDAPPwd = "pwd"

Dim mobjLDAPConn As ADODB.Connection
Dim mobjLDAPComm As ADODB.Command

Public Function LDAPLookup(Optional ByVal astrUID As Variant = "", _
Optional ByVal astrFName As Variant = "", _
Optional ByVal astrLName As Variant = "") As ADODB.Recordset

On Error GoTo Handle_Error

Dim strSQL As String

Set LDAPLookup = Nothing

If mobjLDAPConn Is Nothing Then
Set mobjLDAPConn = New ADODB.Connection
With mobjLDAPConn
.Provider = "ADsDSOObject"
.Properties("User ID") = conLDAPUserID
.Properties("Password") = conLDAPPwd
.Properties("Encrypt Password") = True
.Open "DS Query", conLDAPUserID, conLDAPPwd
End With
Set mobjLDAPComm = New ADODB.Command
With mobjLDAPComm
.ActiveConnection = mobjLDAPConn
.Properties("Page Size") = 99
.Properties("Timeout") = 30 'seconds
.Properties("searchscope") = 0 'Define in ADS_SCOPEENUM; 0
= Base level
.Properties("Cache Results") = False 'do not cache the
result set
End With
End If

Set LDAPLookup = New ADODB.Recordset
With LDAPLookup
.PageSize = 99
.CursorLocation = adUseClient

strSQL = "<LDAP://directory.blah.com/ou=people,o=blah.com>;"
Select Case True
Case (Len(astrUID) > 0)
strSQL = strSQL & "(uid=" & astrUID & ")"
Case ((Len(astrFName) + Len(astrLName)) > 0)
strSQL = strSQL & "(&(givenname=" & astrFName & "*)(sn=" &
astrLName & "*))"
Case Else
End Select
strSQL = strSQL & ";givenname,sn,mail,uid;base"

mobjLDAPComm.CommandText = strSQL
Set LDAPLookup = mobjLDAPComm.Execute
Set .ActiveConnection = Nothing

End With

Exit Function

Handle_Error:

Call HandleErrors("LDAPLookup")

End Function


I have also tried replacing the strSQL variable with:

strSQL = "SELECT uid FROM 'LDAP://blah.com/ou=people,o=blah.com' "
strSQL = strSQL & "WHERE givenname='" & astrFName & "'"
strSQL = strSQL & "AND sn='" & astrLName & "'"

Both versions of the query produce the same results. Further, if I leave
out arguments (to, presumably, use defaults), like the search scope(last
argument in first query version), I always receive the first error noted
above. I generally receive the second error when all arguments are present
or I use the SQL-ish representation of the query. Lastly, I manage dropping
the LDAP connection in my Class_Terminate.

I've been banging heads for three days now and can get nowhere fast.

Any and ALL suggestions are welcome and MOST appreciated!!!

Jeff Allen
Senior Software Engineer
West Group
jeff....@westgroup.com


David Stucki [MS]

unread,
Dec 6, 2001, 3:32:30 PM12/6/01
to
I see that you have the scope set to "base". Have you tried "onelevel" or
"subtree"? A base search will only check the object you pass as the base
of the search, which happens to be an OU. It tries to check that OU's uid
or givenname which an OU doesn't have. This may be the reason why "Table
not found" -- an OU doesn't have that field.

Dave Stucki
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.

Jeff Allen

unread,
Dec 6, 2001, 3:58:40 PM12/6/01
to
Ah, the tiny details we forget to include in postings... :)

I have tried all search scopes on both the command object property setting
and the query syntax (and all combinations thereof, both matching and
non-matching; I was actually instructed by the directory administrator to
use a base level query), and have tried to eliminate the command object and
use just a connection.Execute. My interpretation of the query syntax is
that the OU was the container I was binding or connecting to under which to
execute a query on contained objects.

I'm actually NOT receiving a "Table not found" error, but I AM receiving the
two errors I explicitly noted ("One or more errors occurred ..." and "One or
more arguments invalid").

Thanks for the attempt, though. Any other thoughts?

Jeff Allen
Senior Software Engineer
West Group
jeff....@westgroup.com

"David Stucki [MS]" <a_davs...@microsoft.com> wrote in message
news:H0Dj5UpfBHA.2052@cpmsftngxa08...

Mark Antrim

unread,
Dec 18, 2001, 12:23:09 PM12/18/01
to
Adding a connection property:

mobjLDAPConn.Properties("ADSI Flag") = 0

Should solve your invalid arg err.

"Jeff Allen" <jeff....@westgroup.com> wrote in message news:<3c0fdc01$1...@woodstock.int.westgroup.com>...

0 new messages