--- a/src/server/daemon/ldap_auth.c Tue Jul 16 12:14:13 2013 +0200 +++ b/src/server/daemon/ldap_auth.c Wed Jul 31 11:35:57 2013 +0200 @@ -36,6 +36,14 @@ #include "ldap_auth.h" +static void ws_ldap_close(LDAP *ldap) { +#ifdef SOLARIS + ldap_unbind(ldap); +#else + ldap_unbind_ext_s(ld, NULL, NULL); +#endif +} + AuthDB* create_ldap_authdb(char *name, LDAPConfig *conf) { LDAPAuthDB *authdb = malloc(sizeof(LDAPAuthDB)); authdb->authdb.name = strdup(name); @@ -92,8 +100,8 @@ NULL, &server_cred); if (r != LDAP_SUCCESS) { - //ldap_unbind(ld); - ldap_unbind_ext_s(ld, NULL, NULL); + ws_ldap_close(ld); + fprintf(stderr, "ldap_simple_bind_s failed: %s\n", ldap_err2string(r)); return NULL; } @@ -122,8 +130,8 @@ 1, // size limit &result); if (r != LDAP_SUCCESS) { - //ldap_unbind(ld); - ldap_unbind_ext_s(ld, NULL, NULL); + ws_ldap_close(ld); + fprintf(stderr, "ldap_search_ext_s failed\n"); return NULL; } @@ -150,7 +158,7 @@ } } - ldap_unbind_ext_s(ld, NULL, NULL); + ws_ldap_close(ld); return NULL; } @@ -188,7 +196,6 @@ LDAPUser *user = (LDAPUser*)u; ldap_memfree(user->userdn); // TODO: use connection pool - //ldap_unbind(user->ldap); - ldap_unbind_ext_s(user->ldap, NULL, NULL); + ws_ldap_close(user->ldap); free(user); }