You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by sm...@apache.org on 2022/07/16 10:44:44 UTC

[directory-fortress-core] branch master updated: FC-313 - not closing search cursor

This is an automated email from the ASF dual-hosted git repository.

smckinney pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-fortress-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 0b1538ea FC-313 - not closing search cursor
0b1538ea is described below

commit 0b1538eadb8d825357562e52bb1869c7ce633aad
Author: Shawn McKinney <sm...@symas.com>
AuthorDate: Sat Jul 16 05:44:37 2022 -0500

    FC-313 - not closing search cursor
---
 .../directory/fortress/core/impl/AdminRoleDAO.java | 119 ++++----
 .../directory/fortress/core/impl/AuditDAO.java     | 181 +++++++-----
 .../directory/fortress/core/impl/GroupDAO.java     |  89 +++---
 .../directory/fortress/core/impl/OrgUnitDAO.java   | 167 ++++++-----
 .../directory/fortress/core/impl/PermDAO.java      | 291 +++++++++++--------
 .../directory/fortress/core/impl/PolicyDAO.java    |  57 ++--
 .../directory/fortress/core/impl/RoleDAO.java      | 139 +++++----
 .../apache/directory/fortress/core/impl/SdDAO.java | 175 ++++++-----
 .../directory/fortress/core/impl/UserDAO.java      | 321 +++++++++++++--------
 .../fortress/core/example/ExampleDAO.java          |  26 +-
 10 files changed, 934 insertions(+), 631 deletions(-)

diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleDAO.java
index 8a19af4b..900b47ad 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AdminRoleDAO.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -469,20 +470,30 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
         LdapConnection ld = null;
         String roleRoot = getRootDn( adminRole.getContextId(), GlobalIds.ADMIN_ROLE_ROOT );
         String filter;
-
         try
         {
             String searchVal = encodeSafeText( adminRole.getName(), GlobalIds.ROLE_LEN );
             filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")("
                 + ROLE_NM + "=" + searchVal + "*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, ROLE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot, SearchScope.ONELEVEL, filter, ROLE_ATRS, false,
+                    Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while (searchResults.next())
+                {
+                    roleList.add(unloadLdapEntry(searchResults.getEntry(), sequence++, adminRole.getContextId()));
+                }
+            }
+            catch ( IOException i )
             {
-                roleList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, adminRole.getContextId() ) );
+                String error = "findRoles name [" + adminRole.getName() + "] caught IOException=" + i;
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findRoles name [" + adminRole.getName() + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -490,16 +501,10 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
             String error = "findRoles name [" + adminRole.getName() + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findRoles name [" + adminRole.getName() + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
         }
-
         return roleList;
     }
 
@@ -518,20 +523,30 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
         String roleRoot = getRootDn( adminRole.getContextId(), GlobalIds.ADMIN_ROLE_ROOT );
         String filter;
         String searchVal = null;
-
         try
         {
             searchVal = encodeSafeText( adminRole.getName(), GlobalIds.ROLE_LEN );
             filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")("
                 + ROLE_NM + "=" + searchVal + "*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, limit );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot,
+                    SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, limit ) )
+            {
+                while ( searchResults.next() )
+                {
+                    Entry entry = searchResults.getEntry();
+                    roleList.add( getAttribute( entry, ROLE_NM ) );
+                }
+            }
+            catch ( IOException i )
             {
-                Entry entry = searchResults.getEntry();
-                roleList.add( getAttribute( entry, ROLE_NM ) );
+                String error = "findRoles name [" + adminRole.getName() + "] caught IOException=" + i;
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findRoles name [" + searchVal + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -539,16 +554,10 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
             String error = "findRoles name [" + searchVal + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findRoles name [" + searchVal + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
         }
-
         return roleList;
     }
 
@@ -563,18 +572,28 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
         List<String> roleNameList = new ArrayList<>();
         LdapConnection ld = null;
         String roleRoot = getRootDn( contextId, GlobalIds.ADMIN_ROLE_ROOT );
-
         try
         {
             String filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")";
             filter += "(" + ROLE_OCCUPANT + "=" + userDn + "))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot,
+                SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                while ( searchResults.next() )
+                {
+                    roleNameList.add( getAttribute( searchResults.getEntry(), ROLE_NM ) );
+                }
+            }
+            catch ( IOException i )
             {
-                roleNameList.add( getAttribute( searchResults.getEntry(), ROLE_NM ) );
+                String error = "findAssignedRoles userDn [" + userDn + "] caught IOException=" + i;
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findAssignedRoles userDn [" + userDn + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_OCCUPANT_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -582,16 +601,10 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
             String error = "findAssignedRoles userDn [" + userDn + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ARLE_OCCUPANT_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findAssignedRoles userDn [" + userDn + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ARLE_OCCUPANT_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
         }
-
         return roleNameList;
     }
 
@@ -611,19 +624,29 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
         LdapConnection ld = null;
         String roleRoot = getRootDn( contextId, GlobalIds.ADMIN_ROLE_ROOT );
         String filter = null;
-
         try
         {
             filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")("
                 + GlobalIds.PARENT_NODES + "=*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, DESC_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot,
+                SearchScope.ONELEVEL, filter, DESC_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    descendants.add( unloadDescendants( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
             {
-                descendants.add( unloadDescendants( searchResults.getEntry(), sequence++ ) );
+                String error = "getAllDescendants filter [" + filter + "] caught IOException=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "getAllDescendants filter [" + filter + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -631,16 +654,10 @@ final class AdminRoleDAO extends LdapDataProvider implements PropertyProvider<Ad
             String error = "getAllDescendants filter [" + filter + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "getAllDescendants filter [" + filter + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
         }
-
         return descendants;
     }
 
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
index dc07157d..424149ed 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/AuditDAO.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -273,31 +274,37 @@ final class AuditDAO extends LdapDataProvider
 
             //log.warn("filter=" + filter);
             ld = getLogConnection();
-            SearchCursor searchResults = search( ld, auditRoot,
-                SearchScope.ONELEVEL, filter, AUDIT_AUTHZ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, auditRoot,
+                SearchScope.ONELEVEL, filter, AUDIT_AUTHZ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                AuthZ authZ = getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++ );
-                // todo: fix this workaround. This search will return failed role assign searches as well.  
-                // Work around is to remove the ou=People failed searches from user failed searches on authN.
-                if ( !AuditUtil.getAuthZId( authZ.getReqDN() ).equalsIgnoreCase( "People" ) )
+                long sequence = 0;
+                while ( searchResults.next() )
                 {
-                    auditList.add( authZ );
+                    AuthZ authZ = getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++ );
+                    // todo: fix this workaround. This search will return failed role assign searches as well.
+                    // Work around is to remove the ou=People failed searches from user failed searches on authN.
+                    if ( !AuditUtil.getAuthZId( authZ.getReqDN() ).equalsIgnoreCase( "People" ) )
+                    {
+                        auditList.add( authZ );
+                    }
                 }
             }
+            catch ( IOException i )
+            {
+                String error = "IOException in AuditDAO.searchAuthZs id=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_AUTHN_INVALID_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "CursorException in AuditDAO.searchAuthZs id=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_AUTHN_INVALID_FAILED, error, e );
+            }
         }
         catch ( LdapException e )
         {
             String error = "LdapException in AuditDAO.searchAuthZs id=" + e;
             throw new FinderException( GlobalErrIds.AUDT_AUTHN_INVALID_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "CursorException in AuditDAO.searchAuthZs id=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.AUDT_AUTHN_INVALID_FAILED, error, e );
-        }
         finally
         {
             closeLogConnection( ld );
@@ -341,16 +348,26 @@ final class AuditDAO extends LdapDataProvider
             }
 
             filter += ")";
-
             //System.out.println("filter=" + filter);
             ld = getLogConnection();
-            SearchCursor searchResults = search( ld, auditRoot,
-                SearchScope.ONELEVEL, filter, AUDIT_AUTHZ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, auditRoot,
+                SearchScope.ONELEVEL, filter, AUDIT_AUTHZ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    auditList.add( getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
+            {
+                String error = "IOException in AuditDAO.searchAuthZs id=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
             {
-                auditList.add( getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                String error = "CursorException in AuditDAO.searchAuthZs id=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -358,11 +375,6 @@ final class AuditDAO extends LdapDataProvider
             String error = "LdapException in AuditDAO.searchAuthZs id=" + e;
             throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "CursorException in AuditDAO.searchAuthZs id=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeLogConnection( ld );
@@ -429,18 +441,27 @@ final class AuditDAO extends LdapDataProvider
                 String szTime = TUtil.encodeGeneralizedTime( audit.getBeginDate() );
                 filter += "(" + REQEND + ">=" + szTime + ")";
             }
-
             filter += ")";
-
             //log.warn("filter=" + filter);
             ld = getLogConnection();
-            SearchCursor searchResults = search( ld, auditRoot,
-                SearchScope.ONELEVEL, filter, AUDIT_AUTHZ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, auditRoot,
+                SearchScope.ONELEVEL, filter, AUDIT_AUTHZ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                auditList.add( getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    auditList.add( getAuthzEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
+            {
+                String error = "IOException in AuditDAO.getAllAuthZs id=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "CursorException in AuditDAO.getAllAuthZs id=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -448,11 +469,6 @@ final class AuditDAO extends LdapDataProvider
             String error = "LdapException in AuditDAO.getAllAuthZs id=" + e;
             throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "CursorException in AuditDAO.getAllAuthZs id=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.AUDT_AUTHZ_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeLogConnection( ld );
@@ -517,13 +533,24 @@ final class AuditDAO extends LdapDataProvider
 
             //log.warn("filter=" + filter);
             ld = getLogConnection();
-            SearchCursor searchResults = search( ld, auditRoot,
-                SearchScope.ONELEVEL, filter, AUDIT_BIND_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, auditRoot,
+                SearchScope.ONELEVEL, filter, AUDIT_BIND_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    auditList.add( getBindEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
+            {
+                String error = "IOException in AuditDAO.searchBinds id=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
             {
-                auditList.add( getBindEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                String error = "CursorException in AuditDAO.searchBinds id=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -531,11 +558,6 @@ final class AuditDAO extends LdapDataProvider
             String error = "LdapException in AuditDAO.searchBinds id=" + e;
             throw new FinderException( GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "CursorException in AuditDAO.searchBinds id=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.AUDT_BIND_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeLogConnection( ld );
@@ -569,17 +591,27 @@ final class AuditDAO extends LdapDataProvider
                 String szTime = TUtil.encodeGeneralizedTime( audit.getBeginDate() );
                 filter += "(" + REQEND + ">=" + szTime + ")";
             }
-
             filter += ")";
             //log.warn("filter=" + filter);
             ld = getLogConnection();
-            SearchCursor searchResults = search( ld, auditRoot,
-                SearchScope.ONELEVEL, filter, AUDIT_MOD_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, auditRoot,
+                SearchScope.ONELEVEL, filter, AUDIT_MOD_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    modList.add( getModEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
             {
-                modList.add( getModEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                String error = "searchUserMods caught IOException id=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_MOD_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "searchUserMods caught CursorException id=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_MOD_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -587,11 +619,6 @@ final class AuditDAO extends LdapDataProvider
             String error = "searchUserMods caught LdapException id=" + e;
             throw new FinderException( GlobalErrIds.AUDT_MOD_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "searchUserMods caught CursorException id=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.AUDT_MOD_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeLogConnection( ld );
@@ -663,13 +690,24 @@ final class AuditDAO extends LdapDataProvider
             filter += ")";
             //log.warn("filter=" + filter);
             ld = getLogConnection();
-            SearchCursor searchResults = search( ld, auditRoot,
-                SearchScope.ONELEVEL, filter, AUDIT_MOD_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, auditRoot,
+                SearchScope.ONELEVEL, filter, AUDIT_MOD_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                modList.add( getModEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    modList.add( getModEntityFromLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
+            {
+                String error = "searchAdminMods caught IOException id=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_MOD_ADMIN_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "searchAdminMods caught CursorException id=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.AUDT_MOD_ADMIN_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -677,11 +715,6 @@ final class AuditDAO extends LdapDataProvider
             String error = "searchAdminMods caught LdapException id=" + e;
             throw new FinderException( GlobalErrIds.AUDT_MOD_ADMIN_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "searchAdminMods caught CursorException id=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.AUDT_MOD_ADMIN_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeLogConnection( ld );
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
index af94546c..50d56a46 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/GroupDAO.java
@@ -21,6 +21,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -397,28 +398,33 @@ final class GroupDAO extends LdapDataProvider implements PropertyProvider<Group>
     {
         List<Group> groupList = new ArrayList<>();
         LdapConnection ld = null;
-        SearchCursor searchResults;
         String groupRoot = getRootDn( group.getContextId(), GlobalIds.GROUP_ROOT );
         String filter = null;
-
         try
         {
             String searchVal = encodeSafeText( group.getName(), GlobalIds.ROLE_LEN );
             filter = GlobalIds.FILTER_PREFIX + GROUP_OBJECT_CLASS_IMPL + ")(" + SchemaConstants.CN_AT + "=" + searchVal
                 + "*))";
             ld = getAdminConnection();
-            searchResults = search( ld, groupRoot, SearchScope.ONELEVEL, filter, GROUP_ATRS, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-            while ( searchResults.next() )
+            try( SearchCursor searchResults = search( ld, groupRoot, SearchScope.ONELEVEL, filter, GROUP_ATRS, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                groupList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    groupList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
+            {
+                String error = "find filter [" + filter + "] caught IOException=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "find filter [" + filter + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, e );
             }
-        }
-        catch ( CursorException e )
-        {
-            String error = "find filter [" + filter + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, e );
         }
         catch ( LdapException e )
         {
@@ -444,7 +450,6 @@ final class GroupDAO extends LdapDataProvider implements PropertyProvider<Group>
     {
         List<Group> groupList = new ArrayList<>();
         LdapConnection ld = null;
-        SearchCursor searchResults;
         String groupRoot = getRootDn( user.getContextId(), GlobalIds.GROUP_ROOT );
         String filter = null;
 
@@ -454,19 +459,25 @@ final class GroupDAO extends LdapDataProvider implements PropertyProvider<Group>
             filter = GlobalIds.FILTER_PREFIX + GROUP_OBJECT_CLASS_IMPL + ")(" + SchemaConstants.MEMBER_AT + "="
                 + user.getDn() + "))";
             ld = getAdminConnection();
-            searchResults = search( ld, groupRoot, SearchScope.ONELEVEL, filter, GROUP_ATRS, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, groupRoot, SearchScope.ONELEVEL, filter, GROUP_ATRS, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                groupList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    groupList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
+            {
+                String error = "find filter [" + filter + "] caught IOException=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "find filter [" + filter + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, e );
             }
-        }
-        catch ( CursorException e )
-        {
-            String error = "find filter [" + filter + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, e );
         }
         catch ( LdapException e )
         {
@@ -492,29 +503,33 @@ final class GroupDAO extends LdapDataProvider implements PropertyProvider<Group>
     {
         List<Group> groupList = new ArrayList<>();
         LdapConnection ld = null;
-        SearchCursor searchResults;
         String groupRoot = getRootDn( role.getContextId(), GlobalIds.GROUP_ROOT );
         String filter = null;
-
         try
         {
             encodeSafeText( role.getName(), GlobalIds.ROLE_LEN );
             filter = GlobalIds.FILTER_PREFIX + GROUP_OBJECT_CLASS_IMPL + ")(" + SchemaConstants.MEMBER_AT + "="
                     + role.getDn() + "))";
             ld = getAdminConnection();
-            searchResults = search( ld, groupRoot, SearchScope.ONELEVEL, filter, GROUP_ATRS, false,
-                    Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, groupRoot, SearchScope.ONELEVEL, filter, GROUP_ATRS, false,
+                    Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                groupList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    groupList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException i )
+            {
+                String error = "find filter [" + filter + "] caught IOException=" + i.getMessage();
+                throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "find filter [" + filter + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, e );
             }
-        }
-        catch ( CursorException e )
-        {
-            String error = "find filter [" + filter + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.GROUP_SEARCH_FAILED, error, e );
         }
         catch ( LdapException e )
         {
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java
index 188a51d9..7c631957 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/OrgUnitDAO.java
@@ -335,12 +335,10 @@ final class OrgUnitDAO extends LdapDataProvider
         OrgUnit oe = null;
         LdapConnection ld = null;
         Dn dn = getDn( entity );
-
         try
         {
             ld = getAdminConnection();
             Entry findEntry = read( ld, dn, ORGUNIT_ATRS );
-
             if ( findEntry == null )
             {
                 String warning = "findByKey orgUnit name [" + entity.getName() + "] type ["
@@ -358,7 +356,6 @@ final class OrgUnitDAO extends LdapDataProvider
 
                 throw new FinderException( errCode, warning );
             }
-
             oe = getEntityFromLdapEntry( findEntry, 0, entity.getContextId() );
         }
         catch ( LdapNoSuchObjectException e )
@@ -366,7 +363,6 @@ final class OrgUnitDAO extends LdapDataProvider
             String warning = "findByKey orgUnit name [" + entity.getName() + "] type ["
                 + entity.getType() + "] COULD NOT FIND ENTRY for dn [" + dn + "]";
             int errCode;
-
             if ( entity.getType() == OrgUnit.Type.PERM )
             {
                 errCode = GlobalErrIds.ORG_NOT_FOUND_PERM;
@@ -391,7 +387,6 @@ final class OrgUnitDAO extends LdapDataProvider
             {
                 errCode = GlobalErrIds.ORG_READ_FAILED_USER;
             }
-
             throw new FinderException( errCode, error, e );
         }
         finally
@@ -421,39 +416,52 @@ final class OrgUnitDAO extends LdapDataProvider
             String filter = GlobalIds.FILTER_PREFIX + ORGUNIT_OBJECT_CLASS_NM + ")("
                 + SchemaConstants.OU_AT + "=" + searchVal + "*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, orgUnitRoot,
-                SearchScope.ONELEVEL, filter, ORGUNIT_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, orgUnitRoot,
+                SearchScope.ONELEVEL, filter, ORGUNIT_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                orgUnitList
-                    .add( getEntityFromLdapEntry( searchResults.getEntry(), sequence++, orgUnit.getContextId() ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    orgUnitList
+                            .add( getEntityFromLdapEntry( searchResults.getEntry(), sequence++, orgUnit.getContextId() ) );
+                }
             }
-        }
-        catch ( LdapException e )
-        {
-            String error = "findOrgs search val [" + orgUnit.getName() + "] type [" + orgUnit.getType()
-                + "] root [" + orgUnitRoot + "] caught LdapException=" + e;
-            int errCode;
-
-            if ( orgUnit.getType() == OrgUnit.Type.PERM )
+            catch ( IOException i )
             {
-                errCode = GlobalErrIds.ORG_SEARCH_FAILED_PERM;
+                String error = "findOrgs search val [" + orgUnit.getName() + "] type [" + orgUnit.getType()
+                        + "] root [" + orgUnitRoot + "] caught IOException=" + i;
+                int errCode;
+                if ( orgUnit.getType() == OrgUnit.Type.PERM )
+                {
+                    errCode = GlobalErrIds.ORG_SEARCH_FAILED_PERM;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.ORG_SEARCH_FAILED_USER;
+                }
+                throw new FinderException( errCode, error, i );
             }
-            else
+            catch ( CursorException e )
             {
-                errCode = GlobalErrIds.ORG_SEARCH_FAILED_USER;
+                String error = "findOrgs search val [" + orgUnit.getName() + "] type [" + orgUnit.getType()
+                        + "] root [" + orgUnitRoot + "] caught CursorException=" + e;
+                int errCode;
+                if ( orgUnit.getType() == OrgUnit.Type.PERM )
+                {
+                    errCode = GlobalErrIds.ORG_SEARCH_FAILED_PERM;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.ORG_SEARCH_FAILED_USER;
+                }
+                throw new FinderException( errCode, error, e );
             }
-
-            throw new FinderException( errCode, error, e );
         }
-        catch ( CursorException e )
+        catch ( LdapException e )
         {
             String error = "findOrgs search val [" + orgUnit.getName() + "] type [" + orgUnit.getType()
-                + "] root [" + orgUnitRoot + "] caught CursorException=" + e;
+                + "] root [" + orgUnitRoot + "] caught LdapException=" + e;
             int errCode;
-
             if ( orgUnit.getType() == OrgUnit.Type.PERM )
             {
                 errCode = GlobalErrIds.ORG_SEARCH_FAILED_PERM;
@@ -462,14 +470,12 @@ final class OrgUnitDAO extends LdapDataProvider
             {
                 errCode = GlobalErrIds.ORG_SEARCH_FAILED_USER;
             }
-
             throw new FinderException( errCode, error, e );
         }
         finally
         {
             closeAdminConnection( ld );
         }
-
         return orgUnitList;
     }
 
@@ -490,54 +496,53 @@ final class OrgUnitDAO extends LdapDataProvider
         {
             String filter = "(objectclass=" + ORGUNIT_OBJECT_CLASS_NM + ")";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, orgUnitRoot,
-                SearchScope.ONELEVEL, filter, ORGUNIT_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, orgUnitRoot,
+                SearchScope.ONELEVEL, filter, ORGUNIT_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                ouSet.add( getAttribute( searchResults.getEntry(), SchemaConstants.OU_AT ) );
+                while ( searchResults.next() )
+                {
+                    ouSet.add( getAttribute( searchResults.getEntry(), SchemaConstants.OU_AT ) );
+                }
             }
+            catch ( CursorException e )
+            {
+                String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
+                        + "] caught CursorException=" + e;
+                int errCode;
 
-            searchResults.close();
-        }
-        catch ( LdapException e )
-        {
-            String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
-                + "] caught LdapException=" + e;
-            int errCode;
+                if ( orgUnit.getType() == OrgUnit.Type.PERM )
+                {
+                    errCode = GlobalErrIds.ORG_GET_FAILED_PERM;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.ORG_GET_FAILED_USER;
+                }
 
-            if ( orgUnit.getType() == OrgUnit.Type.PERM )
-            {
-                errCode = GlobalErrIds.ORG_GET_FAILED_PERM;
+                throw new FinderException( errCode, error, e );
             }
-            else
+            catch ( IOException e )
             {
-                errCode = GlobalErrIds.ORG_GET_FAILED_USER;
-            }
+                String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
+                        + "] caught IOException=" + e;
+                int errCode;
 
-            throw new FinderException( errCode, error, e );
-        }
-        catch ( CursorException e )
-        {
-            String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
-                + "] caught CursorException=" + e;
-            int errCode;
+                if ( orgUnit.getType() == OrgUnit.Type.PERM )
+                {
+                    errCode = GlobalErrIds.ORG_GET_FAILED_PERM;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.ORG_GET_FAILED_USER;
+                }
 
-            if ( orgUnit.getType() == OrgUnit.Type.PERM )
-            {
-                errCode = GlobalErrIds.ORG_GET_FAILED_PERM;
+                throw new FinderException( errCode, error, e );
             }
-            else
-            {
-                errCode = GlobalErrIds.ORG_GET_FAILED_USER;
-            }
-
-            throw new FinderException( errCode, error, e );
         }
-        catch ( IOException e )
+        catch ( LdapException e )
         {
             String error = "getOrgs type [" + orgUnit.getType() + "] root [" + orgUnitRoot
-                + "] caught IOException=" + e;
+                + "] caught LdapException=" + e;
             int errCode;
 
             if ( orgUnit.getType() == OrgUnit.Type.PERM )
@@ -580,13 +585,27 @@ final class OrgUnitDAO extends LdapDataProvider
             filter = GlobalIds.FILTER_PREFIX + ORGUNIT_OBJECT_CLASS_NM + ")("
                 + GlobalIds.PARENT_NODES + "=*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, orgUnitRoot,
-                SearchScope.ONELEVEL, filter, DESC_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
+            try ( SearchCursor searchResults = search( ld, orgUnitRoot,
+                SearchScope.ONELEVEL, filter, DESC_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
 
-            while ( searchResults.next() )
+                while ( searchResults.next() )
+                {
+                    descendants.add( unloadDescendants( searchResults.getEntry(), sequence++, orgUnit.getContextId() ) );
+                }
+            }
+            catch ( IOException i )
             {
-                descendants.add( unloadDescendants( searchResults.getEntry(), sequence++, orgUnit.getContextId() ) );
+                String error = "getAllDescendants filter [" + filter + "] caught IOException="
+                        + i.getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, i );
+            }
+            catch ( CursorException e )
+            {
+                String error = "getAllDescendants filter [" + filter + "] caught CursorException="
+                        + e.getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -595,12 +614,6 @@ final class OrgUnitDAO extends LdapDataProvider
                 + e;
             throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "getAllDescendants filter [" + filter + "] caught CursorException="
-                + e.getMessage();
-            throw new FinderException( GlobalErrIds.ARLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
index 423cfba0..1820b2fc 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PermDAO.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -1200,13 +1201,24 @@ class PermDAO extends LdapDataProvider
             filterbuf.append( paSetVal );
             filterbuf.append(  "))" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_ATTRIBUTE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_ATTRIBUTE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    paList.add( unloadPALdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "findPermissionAttributes caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
             {
-                paList.add( unloadPALdapEntry( searchResults.getEntry(), sequence++ ) );
+                String error = "findPermissionAttributes caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -1214,11 +1226,6 @@ class PermDAO extends LdapDataProvider
             String error = "findPermissionAttributes caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPermissionAttributes caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1541,13 +1548,24 @@ class PermDAO extends LdapDataProvider
             filterbuf.append( permOpVal );
             filterbuf.append(  "*))" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, permission.isAdmin() ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "findPermissions caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
             {
-                permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, permission.isAdmin() ) );
+                String error = "findPermissions caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -1555,11 +1573,6 @@ class PermDAO extends LdapDataProvider
             String error = "findPermissions caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPermissions caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1586,13 +1599,24 @@ class PermDAO extends LdapDataProvider
                 filterbuf.append( permObjVal );
                 filterbuf.append(  "))" );
                 ld = getAdminConnection();
-                SearchCursor searchResults = search( ld, permRoot,
-                    SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-                long sequence = 0;
-
-                while ( searchResults.next() )
+                try( SearchCursor searchResults = search( ld, permRoot,
+                    SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
                 {
-                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, permObj.isAdmin() ) );
+                    long sequence = 0;
+                    while ( searchResults.next() )
+                    {
+                        permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, permObj.isAdmin() ) );
+                    }
+                }
+                catch ( IOException e )
+                {
+                    String error = "findPermissions caught IOException=" + e.getMessage();
+                    throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+                }
+                catch ( CursorException e )
+                {
+                    String error = "findPermissions caught CursorException=" + e.getMessage();
+                    throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
                 }
             }
             catch ( LdapException e )
@@ -1600,11 +1624,6 @@ class PermDAO extends LdapDataProvider
                 String error = "findPermissions caught LdapException=" + e;
                 throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
-            catch ( CursorException e )
-            {
-                String error = "findPermissions caught CursorException=" + e.getMessage();
-                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
-            }
             finally
             {
                 closeAdminConnection( ld );
@@ -1656,13 +1675,24 @@ class PermDAO extends LdapDataProvider
                 
                 filterbuf.append("))");
                 ld = getAdminConnection();
-                SearchCursor searchResults = search( ld, permRoot,
-                    SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-                long sequence = 0;
-
-                while ( searchResults.next() )
+                try ( SearchCursor searchResults = search( ld, permRoot,
+                    SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
                 {
-                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, permission.isAdmin() ) );
+                    long sequence = 0;
+                    while ( searchResults.next() )
+                    {
+                        permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, permission.isAdmin() ) );
+                    }
+                }
+                catch ( IOException e )
+                {
+                    String error = "findAnyPermissions caught IOException=" + e.getMessage();
+                    throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+                }
+                catch ( CursorException e )
+                {
+                    String error = "findAnyPermissions caught CursorException=" + e.getMessage();
+                    throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
                 }
             }
             catch ( LdapException e )
@@ -1670,11 +1700,6 @@ class PermDAO extends LdapDataProvider
                 String error = "findAnyPermissions caught LdapException=" + e;
                 throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
-            catch ( CursorException e )
-            {
-                String error = "findAnyPermissions caught CursorException=" + e.getMessage();
-                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
-            }
             finally
             {
                 closeAdminConnection( ld );
@@ -1708,13 +1733,24 @@ class PermDAO extends LdapDataProvider
             filterbuf.append( permObjVal );
             filterbuf.append( "*))" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_OBJ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_OBJ_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPobjLdapEntry( searchResults.getEntry(), sequence++, permObj.isAdmin() ) );
+                }
+            }
+            catch ( IOException e )
             {
-                permList.add( unloadPobjLdapEntry( searchResults.getEntry(), sequence++, permObj.isAdmin() ) );
+                String error = "findPermissions caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findPermissions caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -1722,11 +1758,6 @@ class PermDAO extends LdapDataProvider
             String error = "findPermissions caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPermissions caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1770,13 +1801,24 @@ class PermDAO extends LdapDataProvider
             }
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_OBJ_ATRS, false, maxLimit );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISION_OBJ_ATRS, false, maxLimit ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPobjLdapEntry( searchResults.getEntry(), sequence++, false ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "findPermissions caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
             {
-                permList.add( unloadPobjLdapEntry( searchResults.getEntry(), sequence++, false ) );
+                String error = "findPermissions caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -1784,11 +1826,6 @@ class PermDAO extends LdapDataProvider
             String error = "findPermissions caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPermissions caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1870,13 +1907,24 @@ class PermDAO extends LdapDataProvider
 
             filterbuf.append( ")" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, isAdmin ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, isAdmin ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "findPermissions caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_ROLE_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findPermissions caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_ROLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -1884,11 +1932,6 @@ class PermDAO extends LdapDataProvider
             String error = "findPermissions caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.PERM_ROLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPermissions caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_ROLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1936,13 +1979,26 @@ class PermDAO extends LdapDataProvider
             filterbuf.append( user.getUserId() );
             filterbuf.append( ")))" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, false ) );
+                }
+            }
+            catch ( IOException e )
             {
-                permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, false ) );
+                String error = "findPermissions user [" + user.getUserId()
+                        + "] caught IOException in PermDAO.findPermissions=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findPermissions user [" + user.getUserId()
+                        + "] caught CursorException in PermDAO.findPermissions=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -1951,12 +2007,6 @@ class PermDAO extends LdapDataProvider
                 + "] caught LdapException in PermDAO.findPermissions=" + e;
             throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPermissions user [" + user.getUserId()
-                + "] caught CursorException in PermDAO.findPermissions=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1989,13 +2039,26 @@ class PermDAO extends LdapDataProvider
             filterbuf.append( user.getUserId() );
             filterbuf.append( "))" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, false ) );
+                }
+            }
+            catch ( IOException e )
             {
-                permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, false ) );
+                String error = "findUserPermissions user [" + user.getUserId()
+                        + "] caught IOException in PermDAO.findPermissions=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findUserPermissions user [" + user.getUserId()
+                        + "] caught CursorException in PermDAO.findPermissions=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -2004,12 +2067,6 @@ class PermDAO extends LdapDataProvider
                 + "] caught LdapException in PermDAO.findPermissions=" + e;
             throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findUserPermissions user [" + user.getUserId()
-                + "] caught CursorException in PermDAO.findPermissions=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_USER_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -2068,13 +2125,26 @@ class PermDAO extends LdapDataProvider
 
             filterbuf.append( "))" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, permRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, permRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), PERMISSION_OP_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, isAdmin ) );
+                }
+            }
+            catch ( IOException e )
             {
-                permList.add( unloadPopLdapEntry( searchResults.getEntry(), sequence++, isAdmin ) );
+                String error = "findPermissions user [" + session.getUserId()
+                        + "] caught IOException in PermDAO.findPermissions=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SESS_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findPermissions user [" + session.getUserId()
+                        + "] caught CursorException in PermDAO.findPermissions=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PERM_SESS_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -2083,12 +2153,6 @@ class PermDAO extends LdapDataProvider
                 + "] caught LdapException in PermDAO.findPermissions=" + e;
             throw new FinderException( GlobalErrIds.PERM_SESS_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPermissions user [" + session.getUserId()
-                + "] caught CursorException in PermDAO.findPermissions=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PERM_SESS_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -2157,7 +2221,6 @@ class PermDAO extends LdapDataProvider
         {
             dn = getRootDn( contextId, GlobalIds.PERM_ROOT );
         }
-
         return dn;
     }
 }
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java
index 1564dbb9..e23dc65f 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/PolicyDAO.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
@@ -602,13 +603,24 @@ final class PolicyDAO extends LdapDataProvider
             searchVal = encodeSafeText( policy.getName(), GlobalIds.PWPOLICY_NAME_LEN );
             String szFilter = GlobalIds.FILTER_PREFIX + PW_POLICY_CLASS + ")(" + PW_PWD_ID + "=" + searchVal + "*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, policyRoot,
-                SearchScope.ONELEVEL, szFilter, PASSWORD_POLICY_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, policyRoot,
+                SearchScope.ONELEVEL, szFilter, PASSWORD_POLICY_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    policyArrayList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "findPolicy name [" + searchVal + "] caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
             {
-                policyArrayList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                String error = "findPolicy name [" + searchVal + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -616,11 +628,6 @@ final class PolicyDAO extends LdapDataProvider
             String error = "findPolicy name [" + searchVal + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findPolicy name [" + searchVal + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -645,13 +652,24 @@ final class PolicyDAO extends LdapDataProvider
         {
             String szFilter = "(objectclass=" + PW_POLICY_CLASS + ")";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, policyRoot,
-                SearchScope.ONELEVEL, szFilter, PASSWORD_POLICY_NAME_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, policyRoot,
+                SearchScope.ONELEVEL, szFilter, PASSWORD_POLICY_NAME_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                while ( searchResults.next() )
+                {
+                    Entry entry = searchResults.getEntry();
+                    policySet.add( getAttribute( entry, PW_PWD_ID ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "getPolicies caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
             {
-                Entry entry = searchResults.getEntry();
-                policySet.add( getAttribute( entry, PW_PWD_ID ) );
+                String error = "getPolicies caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -659,11 +677,6 @@ final class PolicyDAO extends LdapDataProvider
             String error = "getPolicies caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "getPolicies caught LdapException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.PSWD_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java
index 96aaf616..59322930 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/RoleDAO.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -523,13 +524,24 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")("
                 + ROLE_NM + "=" + searchVal + "*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, ROLE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot,
+                SearchScope.ONELEVEL, filter, ROLE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    roleList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                }
+            }
+            catch ( IOException e )
             {
-                roleList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                String error = "findRoles filter [" + filter + "] caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findRoles filter [" + filter + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -537,11 +549,6 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             String error = "findRoles filter [" + filter + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findRoles filter [" + filter + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -588,13 +595,24 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
                 filterbuf.append( "))" );
 
                 ld = getAdminConnection();
-                SearchCursor searchResults = search( ld, roleRoot,
-                    SearchScope.ONELEVEL, filterbuf.toString(), ROLE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-                long sequence = 0;
-
-                while ( searchResults.next() )
+                try ( SearchCursor searchResults = search( ld, roleRoot,
+                    SearchScope.ONELEVEL, filterbuf.toString(), ROLE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+                {
+                    long sequence = 0;
+                    while ( searchResults.next() )
+                    {
+                        roleList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, group.getContextId() ) );
+                    }
+                }
+                catch ( IOException e )
                 {
-                    roleList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, group.getContextId() ) );
+                    String error = "groupRoles filter [" + filterbuf.toString() + "] caught IOException=" + e.getMessage();
+                    throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
+                }
+                catch ( CursorException e )
+                {
+                    String error = "groupRoles filter [" + filterbuf.toString() + "] caught CursorException=" + e.getMessage();
+                    throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
                 }
             }
             else
@@ -608,11 +626,6 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             String error = "groupRoles filter [" + filterbuf.toString() + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "groupRoles filter [" + filterbuf.toString() + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -643,13 +656,24 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")("
                 + ROLE_NM + "=" + searchVal + "*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, limit );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot,
+                SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, limit ) )
+            {
+                while ( searchResults.next() )
+                {
+                    Entry entry = searchResults.getEntry();
+                    roleList.add( getAttribute( entry, ROLE_NM ) );
+                }
+            }
+            catch ( IOException e )
             {
-                Entry entry = searchResults.getEntry();
-                roleList.add( getAttribute( entry, ROLE_NM ) );
+                String error = "findRoles filter [" + filter + "] caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findRoles filter [" + filter + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -657,11 +681,6 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             String error = "findRoles filter [" + filter + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findRoles filter [" + filter + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -690,12 +709,23 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             String filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")";
             filter += "(" + SchemaConstants.ROLE_OCCUPANT_AT + "=" + userDn + "))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot,
+                SearchScope.ONELEVEL, filter, ROLE_NM_ATR, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                while ( searchResults.next() )
+                {
+                    roleNameList.add( getAttribute( searchResults.getEntry(), ROLE_NM ) );
+                }
+            }
+            catch ( IOException e )
             {
-                roleNameList.add( getAttribute( searchResults.getEntry(), ROLE_NM ) );
+                String error = "findAssignedRoles userDn [" + userDn + "] caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_OCCUPANT_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findAssignedRoles userDn [" + userDn + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_OCCUPANT_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -703,11 +733,6 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             String error = "findAssignedRoles userDn [" + userDn + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ROLE_OCCUPANT_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "findAssignedRoles userDn [" + userDn + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ROLE_OCCUPANT_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -738,13 +763,24 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             filter = GlobalIds.FILTER_PREFIX + GlobalIds.ROLE_OBJECT_CLASS_NM + ")("
                 + GlobalIds.PARENT_NODES + "=*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, roleRoot,
-                SearchScope.ONELEVEL, filter, DESC_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, roleRoot,
+                SearchScope.ONELEVEL, filter, DESC_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    descendants.add( unloadDescendants( searchResults.getEntry(), sequence++, contextId ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "getAllDescendants filter [" + filter + "] caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
             {
-                descendants.add( unloadDescendants( searchResults.getEntry(), sequence++, contextId ) );
+                String error = "getAllDescendants filter [" + filter + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
             }
         }
         catch ( LdapException e )
@@ -752,11 +788,6 @@ final class RoleDAO extends LdapDataProvider implements PropertyProvider<Role>,
             String error = "getAllDescendants filter [" + filter + "] caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
         }
-        catch ( CursorException e )
-        {
-            String error = "getAllDescendants filter [" + filter + "] caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.ROLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection( ld );
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java
index d2b315cb..4e1aa564 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/SdDAO.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -367,42 +368,55 @@ final class SdDAO extends LdapDataProvider
         {
             objectClass = DSD_OBJECT_CLASS_NM;
         }
-
         try
         {
             String searchVal = encodeSafeText( sdset.getName(), GlobalIds.ROLE_LEN );
             String filter = GlobalIds.FILTER_PREFIX + objectClass + ")(" + SD_SET_NM + "=" + searchVal + "*))";
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, ssdRoot,
-                SearchScope.SUBTREE, filter, SD_SET_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, ssdRoot,
+                SearchScope.SUBTREE, filter, SD_SET_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
             }
-        }
-        catch ( LdapException e )
-        {
-            String error = "search sdset name [" + sdset.getName() + "] type [" + sdset.getType()
-                + "] caught LdapException=" + e;
-            int errCode;
-
-            if ( sdset.getType() == SDSet.SDType.DYNAMIC )
+            catch ( IOException e )
             {
-                errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                String error = "search sdset name [" + sdset.getName() + "] type [" + sdset.getType()
+                        + "] caught IOException=" + e.getMessage();
+                int errCode;
+                if ( sdset.getType() == SDSet.SDType.DYNAMIC )
+                {
+                    errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                }
+                throw new FinderException( errCode, error, e );
             }
-            else
+            catch ( CursorException e )
             {
-                errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                String error = "search sdset name [" + sdset.getName() + "] type [" + sdset.getType()
+                        + "] caught CursorException=" + e.getMessage();
+                int errCode;
+                if ( sdset.getType() == SDSet.SDType.DYNAMIC )
+                {
+                    errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                }
+                throw new FinderException( errCode, error, e );
             }
-
-            throw new FinderException( errCode, error, e );
         }
-        catch ( CursorException e )
+        catch ( LdapException e )
         {
             String error = "search sdset name [" + sdset.getName() + "] type [" + sdset.getType()
-                + "] caught CursorException=" + e.getMessage();
+                + "] caught LdapException=" + e;
             int errCode;
 
             if ( sdset.getType() == SDSet.SDType.DYNAMIC )
@@ -480,38 +494,51 @@ final class SdDAO extends LdapDataProvider
 
             filterbuf.append( ")" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, ssdRoot,
-                SearchScope.SUBTREE, filterbuf.toString(), SD_SET_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            long sequence = 0;
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, ssdRoot,
+                SearchScope.SUBTREE, filterbuf.toString(), SD_SET_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                }
             }
-        }
-        catch ( LdapException e )
-        {
-            String error = "search role [" + role.getName() + "] type [" + type + "] caught LdapException="
-                + e;
-            int errCode;
-
-            if ( type == SDSet.SDType.DYNAMIC )
+            catch ( IOException e )
             {
-                errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                String error = "search role [" + role.getName() + "] type [" + type + "] caught IOException="
+                        + e.getMessage();
+                int errCode;
+                if ( type == SDSet.SDType.DYNAMIC )
+                {
+                    errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                }
+                throw new FinderException( errCode, error, e );
             }
-            else
+            catch ( CursorException e )
             {
-                errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                String error = "search role [" + role.getName() + "] type [" + type + "] caught CursorException="
+                        + e.getMessage();
+                int errCode;
+                if ( type == SDSet.SDType.DYNAMIC )
+                {
+                    errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                }
+                else
+                {
+                    errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                }
+                throw new FinderException( errCode, error, e );
             }
-
-            throw new FinderException( errCode, error, e );
         }
-        catch ( CursorException e )
+        catch ( LdapException e )
         {
-            String error = "search role [" + role.getName() + "] type [" + type + "] caught CursorException="
-                + e.getMessage();
+            String error = "search role [" + role.getName() + "] type [" + type + "] caught LdapException="
+                + e;
             int errCode;
-
             if ( type == SDSet.SDType.DYNAMIC )
             {
                 errCode = GlobalErrIds.DSD_SEARCH_FAILED;
@@ -520,7 +547,6 @@ final class SdDAO extends LdapDataProvider
             {
                 errCode = GlobalErrIds.SSD_SEARCH_FAILED;
             }
-
             throw new FinderException( errCode, error, e );
         }
         finally
@@ -569,13 +595,42 @@ final class SdDAO extends LdapDataProvider
                 }
                 filterbuf.append( "))" );
                 ld = getAdminConnection();
-                SearchCursor searchResults = search( ld, ssdRoot,
-                    SearchScope.SUBTREE, filterbuf.toString(), SD_SET_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-                long sequence = 0;
-
-                while ( searchResults.next() )
+                try ( SearchCursor searchResults = search( ld, ssdRoot,
+                    SearchScope.SUBTREE, filterbuf.toString(), SD_SET_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
                 {
-                    sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                    long sequence = 0;
+                    while ( searchResults.next() )
+                    {
+                        sdList.add( unloadLdapEntry( searchResults.getEntry(), sequence++ ) );
+                    }
+                }
+                catch ( IOException e )
+                {
+                    String error = "search type [" + sdSet.getType() + "] caught IOException=" + e.getMessage();
+                    int errCode;
+                    if ( sdSet.getType() == SDSet.SDType.DYNAMIC )
+                    {
+                        errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                    }
+                    else
+                    {
+                        errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                    }
+                    throw new FinderException( errCode, error, e );
+                }
+                catch ( CursorException e )
+                {
+                    String error = "search type [" + sdSet.getType() + "] caught CursorException=" + e.getMessage();
+                    int errCode;
+                    if ( sdSet.getType() == SDSet.SDType.DYNAMIC )
+                    {
+                        errCode = GlobalErrIds.DSD_SEARCH_FAILED;
+                    }
+                    else
+                    {
+                        errCode = GlobalErrIds.SSD_SEARCH_FAILED;
+                    }
+                    throw new FinderException( errCode, error, e );
                 }
             }
         }
@@ -583,22 +638,6 @@ final class SdDAO extends LdapDataProvider
         {
             String error = "search type [" + sdSet.getType() + "] caught LdapException=" + e;
             int errCode;
-
-            if ( sdSet.getType() == SDSet.SDType.DYNAMIC )
-            {
-                errCode = GlobalErrIds.DSD_SEARCH_FAILED;
-            }
-            else
-            {
-                errCode = GlobalErrIds.SSD_SEARCH_FAILED;
-            }
-            throw new FinderException( errCode, error, e );
-        }
-        catch ( CursorException e )
-        {
-            String error = "search type [" + sdSet.getType() + "] caught CursorException=" + e.getMessage();
-            int errCode;
-
             if ( sdSet.getType() == SDSet.SDType.DYNAMIC )
             {
                 errCode = GlobalErrIds.DSD_SEARCH_FAILED;
diff --git a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
index 831b4559..1ee2945e 100755
--- a/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
+++ b/src/main/java/org/apache/directory/fortress/core/impl/UserDAO.java
@@ -20,6 +20,7 @@
 package org.apache.directory.fortress.core.impl;
 
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -1015,13 +1016,24 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             }
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
-                    Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
+                    Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, user.getContextId() ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String warning = "findUsers userRoot [" + userRoot + "] caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
             {
-                userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, user.getContextId() ) );
+                String warning = "findUsers userRoot [" + userRoot + "] caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1029,11 +1041,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             String warning = "findUsers userRoot [" + userRoot + "] caught LDAPException=" + e;
             throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "findUsers userRoot [" + userRoot + "] caught LDAPException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1068,13 +1075,24 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             filterbuf.append( "*))" );
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID,
-                false, limit );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID,
+                false, limit ) )
+            {
+                while ( searchResults.next() )
+                {
+                    Entry entry = searchResults.getEntry();
+                    userList.add( getAttribute( entry, SchemaConstants.UID_AT ) );
+                }
+            }
+            catch ( IOException e )
             {
-                Entry entry = searchResults.getEntry();
-                userList.add( getAttribute( entry, SchemaConstants.UID_AT ) );
+                String warning = "findUsers caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
+            {
+                String warning = "findUsers caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1082,11 +1100,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             String warning = "findUsers caught LdapException=" + e;
             throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "findUsers caught LDAPException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1146,13 +1159,26 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
 
             filterbuf.append( ")" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String warning = "getAuthorizedUsers role name [" + role.getName() + "] caught IOException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
             {
-                userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                String warning = "getAuthorizedUsers role name [" + role.getName() + "] caught LDAPException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1161,12 +1187,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
                 .getMessage();
             throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "getAuthorizedUsers role name [" + role.getName() + "] caught LDAPException=" + e
-                .getMessage();
-            throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1211,13 +1231,26 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             filterbuf.append( ")" );
             
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                }
+            }
+            catch ( IOException e )
             {
-                userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                String warning = "getAssignedUsers role name [" + role.getName() + "] caught IOException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
+            {
+                String warning = "getAssignedUsers role name [" + role.getName() + "] caught CursorException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1226,12 +1259,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
                 .getMessage();
             throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "getAssignedUsers role name [" + role.getName() + "] caught LDAPException=" + e
-                .getMessage();
-            throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1267,12 +1294,25 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             filterbuf.append( ")" );
             
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                userRoleList.addAll( this.unloadUserRoles( searchResults.getEntry(), getAttribute( searchResults.getEntry(), SchemaConstants.UID_AT ), role.getContextId(), role.getName() ) );
+                while ( searchResults.next() )
+                {
+                    userRoleList.addAll( this.unloadUserRoles( searchResults.getEntry(), getAttribute( searchResults.getEntry(), SchemaConstants.UID_AT ), role.getContextId(), role.getName() ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String warning = "getAssignedUsers role name [" + role.getName() + "] caught IOException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
+            {
+                String warning = "getAssignedUsers role name [" + role.getName() + "] caught CursorException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1281,12 +1321,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
                 .getMessage();
             throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "getAssignedUsers role name [" + role.getName() + "] caught LDAPException=" + e
-                .getMessage();
-            throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1337,12 +1371,25 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             filterbuf.append( "))" );
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID_ATR, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID_ATR, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                while ( searchResults.next() )
+                {
+                    userList.add( unloadUser( searchResults.getEntry() ) );
+                }
+            }
+            catch ( IOException e )
             {
-                userList.add( unloadUser( searchResults.getEntry() ) );
+                String warning = "getAssignedUserIds role name [" + role.getName() + "] caught IOException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
+            {
+                String warning = "getAssignedUserIds role name [" + role.getName() + "] caught CursorException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1351,12 +1398,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
                 .getMessage();
             throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "getAssignedUserIds role name [" + role.getName() + "] caught LDAPException=" + e
-                .getMessage();
-            throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1403,13 +1444,23 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
 
             filterbuf.append( "))" );
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID_ATRS,
-                false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID_ATRS,
+                false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
             {
-                userSet.add( getAttribute( searchResults.getEntry(), SchemaConstants.UID_AT ) );
+                while ( searchResults.next() )
+                {
+                    userSet.add( getAttribute( searchResults.getEntry(), SchemaConstants.UID_AT ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String warning = "getAssignedUsers caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
+            {
+                String warning = "getAssignedUsers caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1417,11 +1468,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             String warning = "getAssignedUsers caught LDAPException=" + e;
             throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "getAssignedUsers caught LDAPException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1455,13 +1501,26 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             filterbuf.append( "))" );
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String warning = "getAssignedUsers admin role name [" + role.getName() + "] caught IOException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_USER_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
             {
-                userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, role.getContextId() ) );
+                String warning = "getAssignedUsers admin role name [" + role.getName() + "] caught CursorException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.ARLE_USER_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1470,12 +1529,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
                 .getMessage();
             throw new FinderException( GlobalErrIds.ARLE_USER_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "getAssignedUsers admin role name [" + role.getName() + "] caught LDAPException=" + e
-                .getMessage();
-            throw new FinderException( GlobalErrIds.ARLE_USER_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1510,13 +1563,26 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             filterbuf.append( "))" );
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID,
-                false, limit );
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), USERID,
+                false, limit ) )
+            {
+                while ( searchResults.next() )
+                {
+                    Entry entry = searchResults.getEntry();
+                    userList.add( getAttribute( entry, SchemaConstants.UID_AT ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String warning = "getAuthorizedUsers role name [" + role.getName() + "] caught IOException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
             {
-                Entry entry = searchResults.getEntry();
-                userList.add( getAttribute( entry, SchemaConstants.UID_AT ) );
+                String warning = "getAuthorizedUsers role name [" + role.getName() + "] caught CursorException=" + e
+                        .getMessage();
+                throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1525,12 +1591,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
                 .getMessage();
             throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "getAuthorizedUsers role name [" + role.getName() + "] caught LDAPException=" + e
-                .getMessage();
-            throw new FinderException( GlobalErrIds.URLE_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1564,13 +1624,24 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             filterbuf.append( "*))" );
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
-                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
+                Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    userList.add( ( unloadLdapEntry( searchResults.getEntry(), sequence++, contextId ) ).getUserId() );
+                }
+            }
+            catch ( IOException e )
             {
-                userList.add( ( unloadLdapEntry( searchResults.getEntry(), sequence++, contextId ) ).getUserId() );
+                String warning = "findUsersList caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
+            {
+                String warning = "findUsersList caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1578,11 +1649,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             String warning = "findUsersList caught LDAPException=" + e;
             throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "findUsersList caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
@@ -1626,13 +1692,23 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             }
 
             ld = getAdminConnection();
-            SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false,
-                maxLimit );
-            long sequence = 0;
-
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, userRoot, SearchScope.ONELEVEL, filterbuf.toString(), defaultAtrs, false, maxLimit ) )
+            {
+                long sequence = 0;
+                while ( searchResults.next() )
+                {
+                    userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, ou.getContextId() ) );
+                }
+            }
+            catch ( IOException e )
+            {
+                String warning = "findUsers caught IOException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
+            }
+            catch ( CursorException e )
             {
-                userList.add( unloadLdapEntry( searchResults.getEntry(), sequence++, ou.getContextId() ) );
+                String warning = "findUsers caught CursorException=" + e.getMessage();
+                throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
             }
         }
         catch ( LdapException e )
@@ -1640,11 +1716,6 @@ final class UserDAO extends LdapDataProvider implements PropUpdater
             String warning = "findUsers caught LDAPException=" + e;
             throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
         }
-        catch ( CursorException e )
-        {
-            String warning = "findUsers caught CursorException=" + e.getMessage();
-            throw new FinderException( GlobalErrIds.USER_SEARCH_FAILED, warning, e );
-        }
         finally
         {
             closeAdminConnection( ld );
diff --git a/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java b/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java
index 64d3bae0..5b14d1b0 100755
--- a/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java
+++ b/src/test/java/org/apache/directory/fortress/core/example/ExampleDAO.java
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.fortress.core.example;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
@@ -279,11 +280,23 @@ public class ExampleDAO extends LdapDataProvider
             ld = getAdminConnection();
             String filter = GlobalIds.FILTER_PREFIX + Arrays.toString(EIds.EXAMPLE_OBJ_CLASS) + ")("
                 + EIds.EXAMPLE_NM + "=" + searchVal + "*))";
-            SearchCursor searchResults = search( ld, exampleRoot,
-                SearchScope.SUBTREE, filter, EXAMPLE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ));
-            while ( searchResults.next() )
+            try ( SearchCursor searchResults = search( ld, exampleRoot,
+                SearchScope.SUBTREE, filter, EXAMPLE_ATRS, false, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, Config.getInstance().getInt(GlobalIds.CONFIG_LDAP_MAX_BATCH_SIZE, GlobalIds.BATCH_SIZE ) ) ) )
             {
-                exampleList.add(getEntityFromLdapEntry(searchResults.getEntry()));
+                while ( searchResults.next() )
+                {
+                    exampleList.add(getEntityFromLdapEntry(searchResults.getEntry()));
+                }
+            }
+            catch ( IOException e )
+            {
+                String error = "findExamples caught IOException=" + e;
+                throw new FinderException( EErrIds.EXAMPLE_SEARCH_FAILED, error, e );
+            }
+            catch ( CursorException e )
+            {
+                String error = "findExamples caught CursorException=" + e;
+                throw new FinderException( EErrIds.EXAMPLE_SEARCH_FAILED, error, e );
             }
         }
         catch (LdapException e)
@@ -292,11 +305,6 @@ public class ExampleDAO extends LdapDataProvider
             LOG.warn(error);
             throw new FinderException(EErrIds.EXAMPLE_SEARCH_FAILED, error);
         }
-        catch ( CursorException e )
-        {
-            String error = "findExamples caught CursorException=" + e;
-            throw new FinderException( EErrIds.EXAMPLE_SEARCH_FAILED, error, e );
-        }
         finally
         {
             closeAdminConnection(ld);