diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-02-01 11:26:25 +0000 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2004-02-01 11:26:25 +0000 |
commit | 670ccc7d643b8e04743542b4336f6830ac065463 (patch) | |
tree | 0b39213b540cc5b6165881bf5c8ef4fd06d5da94 /source4/libads/ldap_utils.c | |
parent | 0d90f4b47b463b2e68dd63ab30a2f022ddece14b (diff) | |
download | samba-670ccc7d643b8e04743542b4336f6830ac065463.tar.gz samba-670ccc7d643b8e04743542b4336f6830ac065463.tar.bz2 samba-670ccc7d643b8e04743542b4336f6830ac065463.zip |
merge:
ldap and krb5 configure tests
libads/*.c and libcli/raw/clikrb5.c from 3.0
metze
(This used to be commit 64b5bfcd73d7626d6f687a641b11e64821144df7)
Diffstat (limited to 'source4/libads/ldap_utils.c')
-rw-r--r-- | source4/libads/ldap_utils.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/source4/libads/ldap_utils.c b/source4/libads/ldap_utils.c index 907f7c8aff..991f16c845 100644 --- a/source4/libads/ldap_utils.c +++ b/source4/libads/ldap_utils.c @@ -28,13 +28,15 @@ this is supposed to catch dropped connections and auto-reconnect */ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope, - const char *exp, + const char *expr, const char **attrs, void **res) { ADS_STATUS status; int count = 3; char *bp; + *res = NULL; + if (!ads->ld && time(NULL) - ads->last_attempt < ADS_RECONNECT_TIME) { return ADS_ERROR(LDAP_SERVER_DOWN); @@ -42,48 +44,58 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope bp = strdup(bind_path); - if (!bp) + if (!bp) { return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); + } while (count--) { - status = ads_do_search_all(ads, bp, scope, exp, attrs, res); + *res = NULL; + status = ads_do_search_all(ads, bp, scope, expr, attrs, res); if (ADS_ERR_OK(status)) { DEBUG(5,("Search for %s gave %d replies\n", - exp, ads_count_replies(ads, *res))); - free(bp); + expr, ads_count_replies(ads, *res))); + SAFE_FREE(bp); return status; } - if (*res) ads_msgfree(ads, *res); + if (*res) + ads_msgfree(ads, *res); *res = NULL; + DEBUG(3,("Reopening ads connection to realm '%s' after error %s\n", ads->config.realm, ads_errstr(status))); + if (ads->ld) { ldap_unbind(ads->ld); } + ads->ld = NULL; status = ads_connect(ads); + if (!ADS_ERR_OK(status)) { DEBUG(1,("ads_search_retry: failed to reconnect (%s)\n", ads_errstr(status))); ads_destroy(&ads); - free(bp); + SAFE_FREE(bp); return status; } } - free(bp); + SAFE_FREE(bp); + + if (!ADS_ERR_OK(status)) + DEBUG(1,("ads reopen failed after error %s\n", + ads_errstr(status))); - DEBUG(1,("ads reopen failed after error %s\n", ads_errstr(status))); return status; } ADS_STATUS ads_search_retry(ADS_STRUCT *ads, void **res, - const char *exp, + const char *expr, const char **attrs) { return ads_do_search_retry(ads, ads->config.bind_path, LDAP_SCOPE_SUBTREE, - exp, attrs, res); + expr, attrs, res); } ADS_STATUS ads_search_retry_dn(ADS_STRUCT *ads, void **res, |