This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Security and the fly likes LDAP connection  close Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "LDAP connection  close" Watch "LDAP connection  close" New topic
Author

LDAP connection close

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
How shall i close the LDAP connection ? i am using Netscape Directory server.
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
I guess closing the ldap initial context s'd suffice.
kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1368
Any update ?
sherjeelmd ghouse
Greenhorn

Joined: Nov 17, 2005
Posts: 7
Call the close on DirContext.

Here is the code. Connection pooling might be helpful for you.

Hashtable env = new Hashtable(11);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");

// Enable connection pooling
env.put("com.sun.jndi.ldap.connect.pool", "true");

// Create one initial context (Get connection from pool)
DirContext ctx = new InitialDirContext(env);

// do something useful with ctx

// Close the context when we're done
ctx.close(); // Return connection to pool


Sherjeel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LDAP connection close
 
Similar Threads
Connection Leaks
H2 database consule lockings
wli7.0sp1 startup problem.. another one
consuquences of not closing ResultSet?
Ldap problem