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
Dave Stucki
Microsoft Developer Support
This posting is provided “AS IS” with no warranties, and confers no rights.
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...
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>...