Package org.apache.directory.shared.ldap.model.cursor

Examples of org.apache.directory.shared.ldap.model.cursor.EntryCursor


     * @throws Exception
     */
    @Test
    public void testSearchWithMissingAttributes() throws Exception
    {
        EntryCursor cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
            SearchScope.OBJECT, "cn", "1.3.6.1.1.16.4", "gn", "entryCSN", "entryUUID" );
        int count = 0;
        Entry entry = null;

        while ( cursor.next() )
        {
            entry = cursor.get();
            assertNotNull( entry );
            count++;
        }
        cursor.close();

        assertEquals( 1, count );
        assertNotNull( entry );

        assertEquals( 3, entry.size() );
View Full Code Here


     * @throws Exception
     */
    @Test
    public void testSearchNoAttributes() throws Exception
    {
        EntryCursor cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
            SearchScope.OBJECT, "1.1" );
        int count = 0;
        Entry entry = null;

        while ( cursor.next() )
        {
            entry = cursor.get();
            assertNotNull( entry );
            count++;
        }
        cursor.close();

        assertEquals( 1, count );
        assertNotNull( entry );

        assertEquals( 0, entry.size() );
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testSearchNoAttributesAndAttributes() throws Exception
    {
        EntryCursor cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
            SearchScope.OBJECT, "1.1", "cn" );
        int count = 0;
        Entry entry = null;

        while ( cursor.next() )
        {
            entry = cursor.get();
            assertNotNull( entry );
            count++;
        }
        cursor.close();

        assertEquals( 1, count );
        assertNotNull( entry );

        assertEquals( 1, entry.size() );
View Full Code Here

     * @throws Exception
     */
    @Test
    public void testSearchNoAttributesAllAttributes() throws Exception
    {
        EntryCursor cursor = connection.search( "cn=user1,ou=users,ou=system", "(objectclass=*)",
            SearchScope.OBJECT, "1.1", "*", "+" );
        int count = 0;
        Entry entry = null;

        while ( cursor.next() )
        {
            entry = cursor.get();
            assertNotNull( entry );
            count++;
        }
        cursor.close();

        assertEquals( 1, count );
        assertNotNull( entry );

        assertEquals( 8, entry.size() );
View Full Code Here

            //assertNotNull( conn.lookup( "cn=barAlias,cn=foo,cn=test,ou=system" ) );
            //assertNotNull( conn.lookup( "cn=fooAlias,cn=bar,cn=test,ou=system" ) );
           
            // Now, do a search
            EntryCursor cursor = conn.search( "cn=foo,cn=test,ou=system", "(objectClass=*)", SearchScope.SUBTREE, "*" );
           
            while ( cursor.next() )
            {
                System.out.println( cursor.get().getDn() );
            }
        }
        finally
        {
            // Cleanup entries now
View Full Code Here

     */
    public Set<String> searchGroups( String filter ) throws Exception
    {
        Set<String> results = new HashSet<String>();

        EntryCursor cursor = connection.search( "ou=groups,ou=system", filter, SearchScope.SUBTREE, "1.1" );

        while ( cursor.next() )
        {
            results.add( cursor.get().getDn().getName() );
        }

        return results;
    }
View Full Code Here

    public void testSearchWithIndexBinaryAttribute() throws Exception
    {
        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );

        // Do a search with a filter based on certificate, get back all the entries
        EntryCursor responses = connection.search( "ou=system", "(userCertificate=*)",
            SearchScope.SUBTREE, "*" );

        int i = 0;

        while ( responses.next() )
        {
            responses.get();
            ++i;
        }

        responses.close();

        // We should have 3 entries
        assertEquals( 4, i );

        // Now, filter the entry with a cn starting with testing, and a certificate
        responses = connection.search( "ou=system", "(&(cn=testing*)(userCertificate=*))", SearchScope.SUBTREE, "*" );

        i = 0;

        while ( responses.next() )
        {
            responses.get();
            ++i;
        }

        responses.close();

        // Now, only 2 entries
        assertEquals( 3, i );

        // Now, just get back the entry with a certificate equals to 0x01 0x02 0x03 0x04
        responses = connection.search( "ou=system", "(userCertificate=\\01\\02\\03\\04)", SearchScope.SUBTREE, "*" );

        i = 0;

        while ( responses.next() )
        {
            responses.get();
            ++i;
        }

        responses.close();

        assertEquals( 2, i );

        // Last, check that searching for an entry using a SUBSTR filter does not work
        responses = connection.search( "ou=system", "(userCertificate=\\01\\02*)", SearchScope.SUBTREE, "*" );

        i = 0;

        while ( responses.next() )
        {
            responses.get();
            ++i;
        }

        responses.close();

        assertEquals( 0, i );
        connection.close();
    }
View Full Code Here

        }

        Entry loadedEntry = null;

        Set<String> csnSet = new HashSet<String>( expectedCsns.length );
        EntryCursor cursor = connection.search( "ou=system", filter.toString(), SearchScope.ONELEVEL, "*", "+" );
       
        while ( cursor.next() )
        {
            loadedEntry = cursor.get();
            csnSet.add( loadedEntry.get( SchemaConstants.ENTRY_CSN_AT ).getString() );
        }
       
        cursor.close();

        assertTrue( csnSet.size() >= expectedCsns.length );

        for ( String csn : expectedCsns )
        {
View Full Code Here

    public void testSearchSubstrOnBinaryAttribute() throws Exception
    {
        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );

        // Check that searching for an entry using a valid SUBSTR filter works
        EntryCursor responses = connection.search( "ou=system", "(binaryAttribute=\\01\\02*)",
            SearchScope.SUBTREE, "*" );

        int i = 0;

        while ( responses.next() )
        {
            responses.get();
            ++i;
        }

        responses.close();

        assertEquals( 1, i );
        connection.close();
    }
View Full Code Here

    private Map<String, Entry> getAllEntries( LdapConnection connection, String dn ) throws Exception
    {
        Map<String, Entry> results = new HashMap<String, Entry>();

        EntryCursor responses = connection.search( dn, "(objectClass=*)", SearchScope.SUBTREE, "+", "*" );

        while ( responses.next() )
        {
            Entry entry = responses.get();

            results.put( entry.getDn().getName(), entry );
        }

        return results;
View Full Code Here

TOP

Related Classes of org.apache.directory.shared.ldap.model.cursor.EntryCursor

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.