same problem hereHi Ajm
Thank you for sharing.
I have the same problem... I can't get this to work.
'ldap_count_entries' returns values other than -1 but 'ldap_first_entryA' still returns 0 (pointer).
Any ideas... anybody?
Ajm wrote:I'm not sure I fully understand what i'm doing
-where did you find the LDAP structure? MSDN says it's an opaque data type (same as LDAPMESSAGE structure)-
Code: Select all
#LDAP_PORT = 389
#LDAP_MSG_ONE = $00 ;retrieves one message at a time
#LDAP_MSG_ALL = $01 ;requests that all results of a search be received before returning all results in a single chain
#LDAP_MSG_RECEIVED = $02 ;indicates that all results retrieved so far should be returned in the result chain
#LDAP_SCOPE_BASE = 0 ;Searches the base entry only.
#LDAP_SCOPE_ONELEVEL = 1 ;Searches all entries in the first level below the base entry, excluding the base entry.
#LDAP_SCOPE_SUBTREE = 2 ;Searches the base entry And all entries in the tree below the base.
#LDAP_SUCCESS = $00 ;The call completed successfully.
Structure LDAP
ld_deref.l
ld_timelimit.l
ld_sizelimit.l
ld_errno.l
ld_matched.s
ld_error.s
EndStructure
lpres.l = 0
Domainname$ = "xxxxx"
base$ = "dc=xxxxx,dc=de"
user$ = "xxxxx"
password$ = "xxxxx"
filter$ = "(objectClass=*)"
If OpenLibrary(0, "wldap32.dll")
Debug "wldap32.dll Library found"
*ld.LDAP = CallCFunction(0, "ldap_init", Domainname$, #LDAP_PORT)
If *ld
Debug "ldap_init successfully called"
rt = CallCFunction(0, "ldap_connect", *ld, 0)
If rt = #LDAP_SUCCESS
Debug "ldap_connect successfully called"
rt = CallCFunction(0, "ldap_simple_bindA", *ld, user$, password$)
If rt <> -1
Debug "ldap_simple_bind successfully called"
rt = CallCFunction(0, "ldap_search_sA", *ld, base$, #LDAP_SCOPE_BASE, filter$, #Null, 0, @lpres)
If rt = #LDAP_SUCCESS
Debug "ldap_search_s successfully called"
rt = CallCFunction(0, "ldap_count_entries", *ld, lpres) ;returns -1 (not successfull) or the number of entries
Debug "ldap_count_entries: "+Str(rt)
If rt <> -1
*fe = CallCFunction(0,"ldap_first_entryA",*ld, *rt)
;***
Debug *fe ;always 0 ??
;***
EndIf
Else
Debug "Unable to search. $" + Hex(CallCFunction(0, "LdapGetLastError"))
EndIf
Else
Debug "Unable to bind. $" + Hex(CallCFunction(0, "LdapGetLastError"))
EndIf
Else
Debug "Unable to connect. $" + Hex(CallCFunction(0, "LdapGetLastError"))
EndIf
CallCFunction(0, "ldap_unbind", *ld)
Else
Debug "Unable to call ldap_init. $" + Hex(CallCFunction(0, "LdapGetLastError"))
EndIf
CloseLibrary(0)
Else
Debug "Unable to open the library. $" + Hex(CallCFunction(0, "LdapGetLastError"))
EndIf
End

