Howard Chu wrote:
> venugopal chinnakotla wrote:
>> Hi Team,
>>
>> We are working on migration of nsldap C sdk to OpenLDAP C sdk for our
>> application client code.
>>
>> We are using OpenLDAP 2.6.7.
>>
>> As part of this migration, we are facing one issue related to timeouts, that
>> we set LDAP Handle using ldap_set_option and calling an API
>> ldap_search_ext_s.
>>
>> With Mozilla NSLDAP, setting PRLDAP_OPT_IO_MAX_TIMEOUT value to zero in LDAP
>> Handle and making ldap_search_ext_s function call. Also passing timeout
>> value (for
>> Ex: 30 seconds) explicitly as one on the argument. This search call is
>> giving an error: "Timeout error."
>>
>>
>> With OpenLDAP, setting LDAP_OPT_TIMEOUT value to zero in LDAP Handle and
>> making ldap_search_ext_s function call. Also passing timeout value (Same
>> value: 30
>> seconds) explicitly as one of the arguments. This search call is giving a
>> successful result instead of Timeout error.
Just re-read your message. Passing a timeout value on the search_ext call takes
precedence over any
timeout option set elsewhere.
> Works For Me.
>
> #include <ldap.h>
> #include <stdio.h>
> #include <sys/time.h>
>
> int main() {
> int rc;
> LDAP *ld = NULL;
> struct timeval tv;
> LDAPMessage *res = NULL;
>
> rc = ldap_initialize( &ld, "ldap://:9011" );
> tv.tv_sec = 0;
> tv.tv_usec = 1;
>
> ldap_set_option( ld, LDAP_OPT_TIMEOUT, &tv );
> rc = ldap_search_ext_s( ld, "dc=example,dc=com", 1, "(objectclass=*)",
> NULL,
> 0, NULL, NULL, NULL, 0, &res );
> printf( "%s\n", ldap_err2string( rc ));
> }
>
>
--
-- Howard Chu
CTO, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc/
Chief Architect, OpenLDAP http://www.openldap.org/project/