summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-07-16 09:48:15 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:28:38 -0500
commit2fc53c947b6c18f5e9761a26792f806ff588e239 (patch)
tree0fa27ae414cb7e354f3e64542b00436568efc08a /source3/libads
parent476c30b9ce38eec8985447fdcd1d3ece97370704 (diff)
downloadsamba-2fc53c947b6c18f5e9761a26792f806ff588e239.tar.gz
samba-2fc53c947b6c18f5e9761a26792f806ff588e239.tar.bz2
samba-2fc53c947b6c18f5e9761a26792f806ff588e239.zip
r23886: add ads_disconnect() function
metze (This used to be commit ba70737b7043cae89dd90f8668a24881212ac6fb)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/ads_struct.c4
-rw-r--r--source3/libads/ldap.c12
-rw-r--r--source3/libads/ldap_utils.c6
3 files changed, 14 insertions, 8 deletions
diff --git a/source3/libads/ads_struct.c b/source3/libads/ads_struct.c
index c66d4e84e8..c769d8ff48 100644
--- a/source3/libads/ads_struct.c
+++ b/source3/libads/ads_struct.c
@@ -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);
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 84ceba2406..c5c43c44c5 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -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
*/
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index 3ad08085bb..16fd32b807 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -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)) {