diff options
-rw-r--r-- | source3/libads/ldap_utils.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c index 105fd2e5b9..58f1c20ad2 100644 --- a/source3/libads/ldap_utils.c +++ b/source3/libads/ldap_utils.c @@ -48,15 +48,16 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope return ADS_ERROR_NT(NT_STATUS_NO_MEMORY); } - while (count--) { - *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", - expr, ads_count_replies(ads, *res))); - SAFE_FREE(bp); - return status; - } + *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", + expr, ads_count_replies(ads, *res))); + SAFE_FREE(bp); + return status; + } + + while (--count) { if (*res) ads_msgfree(ads, *res); @@ -79,6 +80,15 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope SAFE_FREE(bp); return status; } + + *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", + expr, ads_count_replies(ads, *res))); + SAFE_FREE(bp); + return status; + } } SAFE_FREE(bp); |