From bc825f37f327005ce417c8bda658b591e5bca35a Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Tue, 13 Mar 2007 21:01:59 +0000
Subject: [PATCH] Update the LDAPConnection object and the classes that use it to ensure that it can perform an unbind before closing the connection.

---
 opends/src/server/org/opends/server/tools/LDAPSearch.java |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/LDAPSearch.java b/opends/src/server/org/opends/server/tools/LDAPSearch.java
index e0f47cd..e080026 100644
--- a/opends/src/server/org/opends/server/tools/LDAPSearch.java
+++ b/opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -1329,6 +1329,7 @@
       wrapColumn = 0;
     }
 
+    LDAPSearch ldapSearch = null;
     try
     {
       if (initializeServer)
@@ -1386,7 +1387,7 @@
                new PagedResultsControl(true, pageSize, cookieValue)));
           searchOptions.setControls(newControls);
 
-          LDAPSearch ldapSearch = new LDAPSearch(nextMessageID, out, err);
+          ldapSearch = new LDAPSearch(nextMessageID, out, err);
           matchingEntries += ldapSearch.executeSearch(connection, baseDNValue,
                                                       filters, attributes,
                                                       searchOptions,
@@ -1432,7 +1433,7 @@
       }
       else
       {
-        LDAPSearch ldapSearch = new LDAPSearch(nextMessageID, out, err);
+        ldapSearch = new LDAPSearch(nextMessageID, out, err);
         matchingEntries = ldapSearch.executeSearch(connection, baseDNValue,
                                                    filters, attributes,
                                                    searchOptions, wrapColumn);
@@ -1477,7 +1478,14 @@
     {
       if(connection != null)
       {
-        connection.close();
+        if (ldapSearch == null)
+        {
+          connection.close(null);
+        }
+        else
+        {
+          connection.close(ldapSearch.nextMessageID);
+        }
       }
     }
   }

--
Gitblit v1.10.0