[Date Prev][Date Next] [Chronological] [Thread] [Top]

ldap_simple_bind_s fails intermittently, when run in an loop



Hi all,
 
I am trying to use openldap api's to connect to ldap from my code.
I tried to connect to ldap server 1,00,000 times(just intiliazing , binding and unbinding)
Intilaly Binding to the ldap server works fine, but after some time say after reaching more than 10,000 binds. bind continously fails with below error .
"Can't connect to the LDAP server - Cannot assign requested address".
  and error number is 91
 
below is my code snapshot.
int main()
{
    int ret,version,i;
    i=0;
    LDAP  *ld=0;
    while(100000)
    {
        const char *s=0;
        cout<<"count is "<<i++<<endl;
        ld=ldap_init(HOSTNAME,PORTNUMBER);   // HOSTNAME and PORTNUMBER are defined
        if(ld == NULL)
        {
        cout<<" error in initiliaze "<<endl;
        return 2;
        }
        ret=ldap_simple_bind_s(ld,"","");
        ldap_perror(ld,s);
        if(ret != LDAP_SUCCESS)
        {
        cout<<" error in bin "<<ret<<endl;
        cout<<ldap_err2string(ret)<<" is the error"<<endl;
        }
        else
        {
            cout<<"bind success "<<endl;
        }
        ldap_unbind(ld);
        ld=NULL;
    }
    return 0;
}
i am clue less why this happened.
Is there any restriction or bug (already present) that only certain number of binds are possible in a given time.
Your help will be highly help full in my further proceedings.
 
Regards,
Bharath.

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com