File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "LDAP connection  close" Watch "LDAP connection  close" New topic

LDAP connection close

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1382
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: 1382
Any update ?
sherjeelmd ghouse

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.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

I agree. Here's the link:
subject: LDAP connection close