else { for ( NamingEnumeration ii = getRootDSE().getAll(); ii.hasMore();  ) {  Attribute attr = ( Attribute ) ii.next(); AttributeType type = attrRegistry.lookup( attr.getID() ); if ( realIds.contains( type.getOid() ) ) { attrs.put( attr ); } } }
    public NamingEnumeration search( LdapDN base, Map env, ExprNode filter, SearchControls searchCtls )        throws NamingException    {        if ( base.size() == 0 )        {            boolean isObjectScope = searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE;                        // test for (objectClass=*)            boolean isSearchAll = ( ( PresenceNode ) filter ).getAttribute().equalsIgnoreCase( "2.5.4.0" );            /*             * if basedn is "", filter is "(objectclass=*)" and scope is object             * then we have a request for the rootDSE             */            if ( filter instanceof PresenceNode && isObjectScope && isSearchAll )            {                String[] ids = searchCtls.getReturningAttributes();                // -----------------------------------------------------------                // If nothing is asked for then we just return the entry asis.                // We let other mechanisms filter out operational attributes.                // -----------------------------------------------------------                if ( ids == null || ids.length == 0 )                {                    SearchResult result = new SearchResult( "", null, ( Attributes ) getRootDSE().clone(), false );                    return new SingletonEnumeration( result );                }                                // -----------------------------------------------------------                // Collect all the real attributes besides 1.1, +, and * and                // note if we've seen these special attributes as well.                // -----------------------------------------------------------                Set realIds = new HashSet();                boolean containsAsterisk = false;                boolean containsPlus = false;                boolean containsOneDotOne = false;                for ( int ii = 0; ii < ids.length; ii++ )                {                    String id = ids[ii].trim();                    if ( id.equals( "*" ) )                    {                        containsAsterisk = true;                    }                    else if ( id.equals( "+" ) )                    {                        containsPlus = true;                    }                    else if ( id.equals( "1.1" ) )                    {                        containsOneDotOne = true;                    }                    else                    {                        try                        {                            realIds.add( oidRegistry.getOid( id ) );                        }                        catch ( NamingException e )                        {                            realIds.add( id );                        }                    }                }                // return nothing                if ( containsOneDotOne )                {                    SearchResult result = new SearchResult( "", null, new LockableAttributesImpl(), false );                    return new SingletonEnumeration( result );                }                                // return everything                if ( containsAsterisk && containsPlus )                {                    SearchResult result = new SearchResult( "", null, ( Attributes ) getRootDSE().clone(), false );                    return new SingletonEnumeration( result );                }                                Attributes attrs = new LockableAttributesImpl();                if ( containsAsterisk )                {                    for ( NamingEnumeration ii = getRootDSE().getAll(); ii.hasMore(); /**/ )                    {                        // add all user attribute                        Attribute attr = ( Attribute ) ii.next();                        AttributeType type = attrRegistry.lookup( attr.getID() );                        if ( type.getUsage() == UsageEnum.USERAPPLICATIONS )                        {                            attrs.put( attr );                        }                        // add attributes specifically asked for                        else if ( realIds.contains( type.getOid() ) )                        {                            attrs.put( attr );                        }                    }                }                else if ( containsPlus )                {                    for ( NamingEnumeration ii = getRootDSE().getAll(); ii.hasMore(); /**/ )                    {                        // add all operational attributes                        Attribute attr = ( Attribute ) ii.next();                        AttributeType type = attrRegistry.lookup( attr.getID() );                        if ( type.getUsage() != UsageEnum.USERAPPLICATIONS )                        {                            attrs.put( attr );                        }                        // add user attributes specifically asked for                        else if ( realIds.contains( type.getOid() ) )                        {                            attrs.put( attr );                        }                    }                }                SearchResult result = new SearchResult( "", null, attrs, false );                return new SingletonEnumeration( result );            }            throw new LdapNameNotFoundException();        }        Partition backend = getBackend( base );        return backend.search( base, env, filter, searchCtls );    }