Hi,
I have this function in my program, It connects to a LDAP directory
and gets some info. Everything works fine, however, the disconnect
doesn't seem to be working. The connection is not released. Is this a
known bug. If so, what is the workaround ? Also how do I find out what
version of LDAP SDK am I using. I am troubleshooting someone else's
code ...

Thanks 
Shan

public int getBuyerUserInfo(String ldapHost, String ldapPort,
                                     String ldapUser, String
ldapPasswd,
                                     String rootDN, String buyerLogin)
        {

                LDAPConnection   ldapConn = null;
                LDAPSearchResults   resultSet;

                try
                {
                        ldapConn = new LDAPConnection();
                        int port = ( Integer.valueOf(ldapPort) ).intValue();
                        ldapConn.connect( ldapHost, port );
                        ldapConn.authenticate(ldapUser, ldapPasswd);

                        String searchFilter = "uid=" + buyerLogin;
                        
                        resultSet = ldapConn.search(rootDN, LDAPv2.SCOPE_SUB, 
searchFilter,
null, false);

                        LDAPEntry entry = resultSet.next();
                        if(entry!=null)
                        {
                                LDAPAttribute guidAttr = 
entry.getAttribute("iplanetecguid");
                                Enumeration enumVals = guidAttr.getStringValues();
                                bxUserGuid = (String) enumVals.nextElement();
                        }
                        else{
                                return 0;
                        }
                }
                catch (LDAPException e) {
                        debug.error(e.getMessage());
                        debug.error(e.getClass().getName());
                } catch(Exception e) {
                        debug.error("Other Exception caught in getBuyerUserInfo");
                        debug.error(e.getMessage());
                        debug.error(e.getClass().getName());
                }
                finally
                {
                        try {
                                debug.message("In finally, calling disconnect");
                                ldapConn.disconnect();
                        } catch (LDAPException e) {
                                debug.error("LDAP disconnect failed");
                        }
                }
                return 1;
        }

Reply via email to