if ( env.containsKey( "server.disable.anonymous" ) )
StartupConfiguration config = ( StartupConfiguration ) Configuration.toConfiguration( env );  if ( ! config.isAllowAnonymousAccess() )
    public LdapContext getLdapContext( IoSession session, Control[] connCtls, boolean allowAnonymous )        throws NamingException    {        LdapContext ctx = null;        synchronized ( contexts )        {            ctx = ( LdapContext ) contexts.get( session );        }        // there is no context so its an implicit bind, no bind operation is being performed        if ( ctx == null && allowAnonymous )        {            // if configuration says disable anonymous binds we throw exection            if ( env.containsKey( "server.disable.anonymous" ) )            {                throw new LdapNoPermissionException( "Anonymous binds have been disabled!" );            }            if ( env.containsKey( "server.use.factory.instance" ) )            {                InitialContextFactory factory = ( InitialContextFactory ) env.get( "server.use.factory.instance" );                if ( factory == null )                {                    throw new NullPointerException( "server.use.factory.instance was set in env but was null" );                }                ctx = ( LdapContext ) factory.getInitialContext( env );            }            else            {                Hashtable cloned = ( Hashtable ) env.clone();                cloned.put( Context.SECURITY_AUTHENTICATION, "none" );                cloned.remove( Context.SECURITY_PRINCIPAL );                cloned.remove( Context.SECURITY_CREDENTIALS );                ctx = new InitialLdapContext( cloned, connCtls );            }        }        // the context came up non null so we binded explicitly and op now is not bind        else if ( ctx != null && allowAnonymous )        {            ServerLdapContext slc = null;            if ( !( ctx instanceof ServerLdapContext ) )            {                slc = ( ServerLdapContext ) ctx.lookup( "" );            }            else            {                slc = ( ServerLdapContext ) ctx;            }            boolean isAnonymousUser = slc.getPrincipal().getName().trim().equals( "" );            StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration( env );            // if the user principal is anonymous and the configuration does not allow anonymous binds we            // prevent the operation by blowing a NoPermissionsException            if ( isAnonymousUser && !cfg.isAllowAnonymousAccess() )            {                throw new LdapNoPermissionException( "Anonymous binds have been disabled!" );            }        }        return ctx;    }