From 415c6e6fc68251358f393cc551da180fb911346d Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 8 Sep 2015 21:34:23 +0200 Subject: Make sure LDAPConnections are cleaned up on login, and if connect is called again. --- src/main/java/com/c2kernel/process/Gateway.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 2ce4d26..eed75a0 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -25,6 +25,7 @@ import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Language; import com.c2kernel.utils.Logger; import com.c2kernel.utils.Resource; +import com.novell.ldap.LDAPConnection; /************************************************************************** @@ -178,6 +179,9 @@ public class Gateway throws InvalidDataException, ClusterStorageException { + if (mLDAPLookup!=null) + mLDAPLookup.disconnect(); + LDAPProperties ldapProps = new LDAPProperties(); if( ldapProps.mHost != null && ldapProps.mPort != null && @@ -226,7 +230,8 @@ public class Gateway ldapProps.mPassword = agentPassword; try { - LDAPLookup.createConnection(ldapProps); + LDAPConnection login = LDAPLookup.createConnection(ldapProps); + login.disconnect(); return (AgentProxy)getProxyManager().getProxy(mLDAPLookup.getRoleManager().getAgentPath(agentName)); } catch (Exception ex) { Logger.error(ex); @@ -246,7 +251,9 @@ public class Gateway static public AgentProxy connect(String agentName, String agentPassword) throws InvalidDataException, ObjectNotFoundException { - + if (mLDAPLookup!=null) + mLDAPLookup.disconnect(); + LDAPProperties ldapProps = new LDAPProperties(); if (ldapProps.mHost!=null && ldapProps.mPort!= null && ldapProps.mLocalPath!=null ) { -- cgit v1.2.3