[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
ldap_bind_s() can't connect LDAP Server
Hi List,
I hope I'm on the right mailinglist of openldap. I got some problem,
when performing a search of one object several times....
I'm searching for the entry test. I've created the source code below to
test a problem I had in a larger program. First it looked pretty good,
but after a while I got the following error:
ldap_bind_s: Can't contact LDAP server (81)
ldap_bind_s: Can't contact LDAP server (81)
ldap_bind_s: Can't contact LDAP server (81)
..
..
..
First I thought I didn't cleanly free the variables, but the code below
should be correct?!?
Is this problem openldap(-software) related or did I make a big
mistake....?
I'm using the stable package which comes with Debian Sarge...(version of
openldap: 2.2.23-8)
Thanks in Advance for any answer..
Regards
Robin
PS:
The following source code I created to show what I did:
--------------------------------------------------------------------
#include <stdio.h>
#include <string.h>
#include <ldap.h>
char *ldap_host = "localhost";
char *login_dn = "cn=admin,dc=datapark,dc=ch";
char *root_dn = "dc=test,dc=datapark,dc=ch";
char *login_pw = "te*st89";
int search_base(char *base) {
LDAP *ldap;
LDAPMessage *msg;
char *filter = "(objectClass=*)";
if(( ldap = ldap_init(ldap_host, LDAP_PORT)) == NULL) {
fprintf(stderr, "Couldn't connect to ldap host.\n");
return 1;
}
if(ldap_bind_s(ldap, login_dn, login_pw, LDAP_AUTH_SIMPLE) !=
LDAP_SUCCESS) {
ldap_perror(ldap, "ldap_bind_s");
ldap_unbind(ldap);
return 2;
}
// perform an ldap search to get downstream and upstream values
of month!
if(ldap_search_s(ldap, base, LDAP_SCOPE_SUBTREE, filter, NULL,
0, &msg) != LDAP_SUCCESS) {
ldap_perror(ldap, "ldap_search_s");
ldap_msgfree(msg);
ldap_unbind(ldap);
return 3;
}
ldap_msgfree(msg);
ldap_unbind_s(ldap);
return 0;
}
int main(void) {
int i;
char *base = "dc=test,dc=datapark,dc=ch";
for(i = 0; i < 100000; i++) {
search_base(base);
}
return 0;
}