void *res;
status = ads_do_search_retry(ads, "", LDAP_SCOPE_BASE, "(objectclass=*)", attrs, &res);
- if (!ADS_ERR_OK(status)) return status;
+ if (!ADS_ERR_OK(status))
+ return status;
if (ads_count_replies(ads, res) != 1) {
return ADS_ERROR(LDAP_NO_RESULTS_RETURNED);
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)));
}
rc = ads_USN(ads, seq);
+
if (!ADS_ERR_OK(rc)) {
- /* its a dead connection */
- ads_destroy(&ads);
+
+ /* its a dead connection ; don't destroy it
+ through since ads_USN() has already done
+ that indirectly */
+
domain->private = NULL;
}
return ads_ntstatus(rc);
rc = ads_domain_sid(ads, sid);
if (!ADS_ERR_OK(rc)) {
- /* its a dead connection */
- ads_destroy(&ads);
+
+ /* its a dead connection; don't destroy it though
+ since that has already been done indirectly
+ by ads_domain_sid() */
+
domain->private = NULL;
}