> -----Original Message----- > From: > [email protected] > > [mailto:[email protected] > illa.org] On Behalf Of Xu, Qiang (FXSGSC) > Sent: Friday, September 11, 2009 10:45 AM > To: [email protected] > Subject: timeout on ldap_simple_bind_s() > > Hi, all: > > Recently, I am hit by a timeout issue of ldap_simple_bind_s(). > > For example, the correct LDAP server is "13.198.97.16". But, > when I mis-configured the server to be "13.198.98.16", > ldap_simple_bind_s() takes almost 5 minutes to return. That > means, it blocks for 5 mins, which is really unacceptable. > > Is there any timeout option that can be set by > ldap_set_option(), before the call of ldap_simple_bind_s()?
Hi, Anton: In discussion at http://groups.google.com/group/mozilla.dev.tech.ldap/browse_thread/thread/9c1d47b48d440e00/2ec6a0a0e661f6ca, your suggestion is to use the async API ldap_simple_bind() instead of the synchronous API ldap_simple_bind_s(), and specify a timeout value for ldap_result(). Borrowing your idea, I tried the following code: ================================================ static int ldap_simple_bind_ext_s( LDAP *ld, const char *dn, const char *passwd, struct timeval *timeout ) ; //xq ... //xq.0 static int ldap_simple_bind_ext_s( LDAP *ld, const char *dn, const char *passwd, struct timeval *timeout ) { int msgid; LDAPMessage *result; if ( ld == NULL ) { return( LDAP_PARAM_ERROR ); } if ( (msgid = ldap_simple_bind( ld, dn, passwd )) == -1 ) return( ldap_get_lderrno( ld, NULL, NULL ) ); if ( ldap_result( ld, msgid, 1, timeout, &result ) == -1 ) return( ldap_get_lderrno( ld, NULL, NULL ) ); return( ldap_result2error( ld, result, 1 ) ); } //xq.1 ... static AbaInitStatus aba_ldap_init_p(LDAP **ldapSearchHandle, bool_t testFlag, char* username, char* password, SM_Session_Information_Type *sessionInformation) { ... struct timeval bindTimeOut; //xq ... bindTimeOut.tv_sec = 10; //xq ... LOGINFO("Secure Login"); #if 0 ldapStatus = ldap_simple_bind_s(ldapHandle, ldapServerConfigData.loginName, ldapServerConfigData.loginPassword); #else //xq.0 ldapStatus = ldap_simple_bind_ext_s(ldapHandle, ldapServerConfigData.loginName, ldapServerConfigData.loginPassword, &bindTimeout); #endif //xq.1 ... } ================================================ To my surprise, it doesn't work. Here is the log: ================================================ <distribution> (Fri Sep 11 2009 15:51:12.132) <p5338,t813147760,aba_ldap_interface.c,1393> INFO>> Secure Login <distribution> (Fri Sep 11 2009 15:54:21.132) <p5338,t813147760,aba_ldap_interface.c,1404> INFO>> ldap_simple_bind_ext_s return 91 <distribution> (Fri Sep 11 2009 15:54:21.132) <p5338,t813147760,aba_ldap_interface.c,1409> INFO>> LDAP BIND: Value of ldapStatus 91 <distribution> (Fri Sep 11 2009 15:54:21.132) <p5338,t813147760,aba_ldap_interface.c,1478> ERROR>> LDAP BIND: Value of ldap failure status and text 91 Can't connect to the LDAP server ================================================ The wrapper ldap_simple_bind_ext_s() still returns after around 3 mins, not 10 seconds. Anything wrong with my code? Thanks, Xu Qiang _______________________________________________ dev-tech-ldap mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-ldap
