Package javax.naming.directory

Examples of javax.naming.directory.Attributes


    /**
     * Creation of required attributes of a person entry.
     */
    private Attributes getPersonAttributes( String sn, String cn ) throws LdapException
    {
        Attributes attributes = LdifUtils.createJndiAttributes(
            "objectClass: top",
            "objectClass: person",
            "cn", cn,
            "sn", sn );

View Full Code Here


        list.close();

        assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );

        Attributes attrs = map.get( "ou=testing01,ou=system" );

        assertNotNull( attrs.get( SchemaConstants.OU_AT ) );
        assertNotNull( attrs.get( "integerAttribute" ) );

        assertEquals( 0, attrs.get( SchemaConstants.OU_AT ).size() );
        assertEquals( 0, attrs.get( "integerAttribute" ).size() );

        assertNull( attrs.get( SchemaConstants.ENTRY_UUID_AT ) );
        assertNull( attrs.get( SchemaConstants.CREATORS_NAME_AT ) );
    }
View Full Code Here

            { "*", "+" } );

        LdapContext nullRootCtx = getRootContext( getService() );

        NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(objectClass=*)", controls );
        Attributes rootDse = null;

        while ( list.hasMore() )
        {
            SearchResult result = list.next();
            rootDse = result.getAttributes();
        }

        list.close();

        assertNotNull( rootDse );

        assertEquals( 10, rootDse.size() );
        assertNotNull( rootDse.get( "objectClass" ) );
        assertNotNull( rootDse.get( "entryUUID" ) );
        assertNotNull( rootDse.get( "namingContexts" ) );
        assertNotNull( rootDse.get( "subschemaSubentry" ) );
        assertNotNull( rootDse.get( "supportedControl" ) );
        assertNotNull( rootDse.get( "supportedExtension" ) );
        assertNotNull( rootDse.get( "supportedFeatures" ) );
        assertNotNull( rootDse.get( "supportedLDAPVersion" ) );
        assertNotNull( rootDse.get( "vendorName" ) );
        assertNotNull( rootDse.get( "vendorVersion" ) );
    }
View Full Code Here

            { "*", "+" } );

        LdapContext nullRootCtx = getRootContext( getService() );

        NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(ou=testing01)", controls );
        Attributes rootDse = null;

        while ( list.hasMore() )
        {
            SearchResult result = list.next();
            rootDse = result.getAttributes();
View Full Code Here

            { "*", "+" } );

        LdapContext nullRootCtx = getRootContext( getService() );

        NamingEnumeration<SearchResult> list = nullRootCtx.search( "", "(|(&(objectclass=posixGroup)(|(gidnumber=1)(gidnumber=1)))(objectClass=posixGroupp))", controls );
        Attributes rootDse = null;

        while ( list.hasMore() )
        {
            SearchResult result = list.next();
            rootDse = result.getAttributes();
View Full Code Here

    public void testSearchingNewSchemaElements() throws Exception
    {
        DirContext ctx = getWiredContext( getLdapServer() );

        // create an entry with the schema objectClass personActiveDirectory
        Attributes person = new BasicAttributes( "objectClass", "top", true );
        person.get( "objectClass" ).add( "person" );
        person.get( "objectClass" ).add( "personActiveDirectory" );
        person.put( "cn", "foobar" );
        person.put( "sn", "bar" );
        person.put( "pwdLastSet", "3" );
        person.put( "SourceAD", "blah" );
        person.put( "useraccountcontrol", "7" );
        person.put( "sAMAccountName", "foobar" );
        ctx.createSubcontext( "cn=foobar,ou=system", person );

        // Confirm creation with a lookup
        Attributes read = ctx.getAttributes( "cn=foobar,ou=system" );
        assertNotNull( read );
        assertEquals( "3", read.get( "pwdLastSet" ).get() );

        // Now search for foobar with pwdLastSet value of 3
        SearchControls searchControls = new SearchControls();
        searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
        NamingEnumeration<SearchResult> results = ctx.search( "ou=system", "(pwdLastSet=3)", searchControls );
        assertTrue( results.hasMore() );
        SearchResult result = results.next();
        assertNotNull( result );
        assertEquals( "cn=foobar", result.getName() );
        Attributes attributes = result.getAttributes();
        assertEquals( "3", attributes.get( "pwdLastSet" ).get() );
        results.close();

        // Now search with bogus value for pwdLastSet
        results = ctx.search( "ou=system", "(pwdLastSet=300)", searchControls );
        assertFalse( results.hasMore() );
View Full Code Here

            { "objectClasses" } );
        NamingEnumeration<SearchResult> results = ctx.search( "cn=schema", "(ObjectClass=*)", searchControls );

        assertTrue( results.hasMore() );
        SearchResult result = results.next();
        Attributes entry = result.getAttributes();

        Attribute objectClasses = entry.get( "objectClasses" );
        NamingEnumeration<?> ocs = objectClasses.getAll();

        while ( ocs.hasMore() )
        {
            String oc = ( String ) ocs.nextElement();
View Full Code Here

        list.close();

        assertEquals( "Expected number of results returned was incorrect", 1, map.size() );
        assertTrue( map.containsKey( "ou=testing02,ou=system" ) );
        Attributes attrs = map.get( "ou=testing02,ou=system" );
        assertEquals( 0, attrs.size() );
    }
View Full Code Here

        list.close();

        assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
        assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
        Attributes attrs = map.get( "ou=testing00,ou=system" );
        assertEquals( "normalized creator's name", "0.9.2342.19200300.100.1.1=admin,2.5.4.11=system", attrs.get(
            "creatorsName" ).get() );
    }
View Full Code Here

        list.close();

        assertEquals( "Expected number of results returned was incorrect!", 1, map.size() );
        assertTrue( map.containsKey( "ou=testing00,ou=system" ) );
        Attributes attrs = map.get( "ou=testing00,ou=system" );
        assertEquals( "normalized creator's name", "uid=admin,ou=system", attrs.get( "creatorsName" ).get() );
    }
View Full Code Here

TOP

Related Classes of javax.naming.directory.Attributes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.