r23886: add ads_disconnect() function
authorStefan Metzmacher <metze@samba.org>
Mon, 16 Jul 2007 09:48:15 +0000 (09:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:28:38 +0000 (12:28 -0500)
metze
(This used to be commit ba70737b7043cae89dd90f8668a24881212ac6fb)

source3/libads/ads_struct.c
source3/libads/ldap.c
source3/libads/ldap_utils.c

index c66d4e84e8e3029661b417618eb5d7a07536e476..c769d8ff48f9263469b099e2b125ae80f9e0a676 100644 (file)
@@ -141,9 +141,7 @@ void ads_destroy(ADS_STRUCT **ads)
 
                is_mine = (*ads)->is_mine;
 #if HAVE_LDAP
-               if ((*ads)->ld) {
-                       ldap_unbind((*ads)->ld);
-               }
+               ads_disconnect(*ads);
 #endif
                SAFE_FREE((*ads)->server.realm);
                SAFE_FREE((*ads)->server.workgroup);
index 84ceba2406ada958d86880130920390fd68e7248..c5c43c44c5ae87ac0245322328d2eec15fd7e3bb 100644 (file)
@@ -465,6 +465,18 @@ got_connection:
        return ads_sasl_bind(ads);
 }
 
+/**
+ * Disconnect the LDAP server
+ * @param ads Pointer to an existing ADS_STRUCT
+ **/
+void ads_disconnect(ADS_STRUCT *ads)
+{
+       if (ads->ld) {
+               ldap_unbind(ads->ld);
+               ads->ld = NULL;
+       }
+}
+
 /*
   Duplicate a struct berval into talloc'ed memory
  */
index 3ad08085bb2970915336068892bc5eec7917af0d..16fd32b80795e7905701e0b720562ac9debbfbd7 100644 (file)
@@ -75,11 +75,7 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT *ads, const char *bind
                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;
+               ads_disconnect(ads);
                status = ads_connect(ads);
                
                if (!ADS_ERR_OK(status)) {