[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: How get more detailed error information than the provided by ldap_err2string?
- To: openldap-technical@openldap.org
- Subject: Re: How get more detailed error information than the provided by ldap_err2string?
- From: Werner M <wxxx333@gmail.com>
- Date: Sat, 8 Mar 2014 19:09:56 -0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to; bh=SpsaQ3ELBkl0BFSiWMWqkNXQRgu6plZ/0z0tF14FoUg=; b=eXEho6FRgnFlQrO1qT1eY9xtzdrEEJV9Mris49iOgF2fKC2Ru8eiyHrtfxdeCJ/gy9 E09HqP3SdcF9bZ3tpvA8w/bOA9JKKDCBp8IypAKTXC2GEZCXTaatuTZxbsbUUTxAmcU1 hrGiJ3XOSZwiLt1C2rh7jBDcrm21NUMhr1da3USjlFIrFmwI9L8coZ2QZY8AIW6bSgDJ RmCuGu79eSKhzJKA3yfgpMbTVUMBw18WlEQ0/itwIk0QsVKm45hQidmEaxRThdrHWzeE SD4CYELvC+Iug+gp1aEBfunZnmxFOKMsIBv5Q6vnN44H7mnBO5dN8Qg5w+IgJatP5uOU GM2g==
- In-reply-to: <531B8854.3080108@symas.com>
- References: <CAF4vVMRTd6St8RS3nnnY_Po0dxdjZpbjEOdD4fGsOB+Q8UGRCg@mail.gmail.com> <531B8854.3080108@symas.com>
On 08/03/2014, at 18:15, Howard Chu <hyc@symas.com> wrote:
> Werner - Google wrote:
>> Hi,
>>
>> I've the sample code bellow, and when i intentionally put the wrong
>> credentials, i get from "ldap_err2string( rc ) the error message:
>> "Invalid credentials".
>
> Read the ldap_get_option(3), ldap_bind(3), and ldap_result(3) manages.
Thx for the quick reply.
I've read them many times, but I'm still unable to understand/find a way to use the ldap_result with "synchronous" function of bind/search.
If i understood the man pages correctly ldap_result is a companion to ldap_simple_bind/ldap_search_ext (asynchronous) . Is there a way of using it with the ldap_simple_bind_s()/ ldap_search_ext_s() functions? Or should/must i take the time and rewrite my entire code and find a way of doing things using the asynchronous functions?
i noted that i've not provided the library versions:
I'm on ubuntu, with :
$ slapd -V
@(#) $OpenLDAP: slapd (Ubuntu) (Oct 8 2013 20:51:43) $
buildd@akateko:/build/buildd/openldap-2.4.31/debian/build/servers/slapd
$ ldapsearch -VV
ldapsearch: @(#) $OpenLDAP: ldapsearch (Ubuntu) (Oct 8 2013 20:50:56) $
buildd@akateko:/build/buildd/openldap-2.4.31/debian/build/clients/tools
(LDAP library: OpenLDAP 20431)
>> ---
>> sample code:
>>
>>
>> if ( (ld = (LDAP *)ldap_init( pHostName, iPortNum )) == NULL ) {
>> perror( "ldap_init failed. Reason?:" );
>> exit ( 1 );
>> }
>>
>> if ( (rc=ldap_set_option( ld, LDAP_OPT_PROTOCOL_VERSION, &version)) !=
>> LDAP_SUCCESS ){
>> fprintf( stderr, "ldap_set_option(LDAP_OPT_PROTOCOL_VERSION): %s\n",
>> ldap_err2string( rc ) );
>> exit( 1 );
>> }
>>
>> if ( (rc=ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF)) != LDAP_SUCCESS){
>> fprintf( stderr, "ldap_set_option(LDAP_OPT_REFERRALS): %s\n", ldap_err2string(
>> rc ));
>> exit( 1 );
>> }
>>
>> rc = ldap_simple_bind_s( ld, "auth_dn", "auth_pw" );
>>
>>
>> if ( rc != LDAP_SUCCESS ) {
>> fprintf( stderr, "ldap_simple_bind_s() Failed: %s [%d]\n",
>> ldap_err2string(rc), rc);
>> ldap_unbind_s(ld); /* try unbind the failed connection anyway */
>> exit ( 1 );
>> }
>>
>>
>
>
> --
> -- Howard Chu
> CTO, Symas Corp. http://www.symas.com
> Director, Highland Sun http://highlandsun.com/hyc/
> Chief Architect, OpenLDAP http://www.openldap.org/project/