public static void closeContext(LdapContext ctx) {
        try {
            if (ctx != null) {
                ctx.close();
            }
        } catch (NamingException e) {
            LOGGER.error("Exception while closing LDAP context. ", e);
        }
    }
Closes an LDAP context, logging any errors, but not throwing
an exception if there is a failure.

@param ctx the LDAP context to close.
core/src/main/java/org/apache/shiro/realm/ldap/LdapUtils.java