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

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


    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


        modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "description", description3 );

        sysRoot.modify( dn, modification );

        // Search Entry
        EntryCursor cursor = sysRoot.search( dn, "(cn=Fiona Apple)",
            SearchScope.ONELEVEL, "*" );

        while ( cursor.next() )
        {
            Entry result = cursor.get();
            assertTrue( result.contains( "description", description1, description2, description3 ) );
        }

        cursor.close();

        // Remove the person entry
        sysRoot.delete( dn );
    }
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 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() );
        }
       
        cursor.close();

        return results;
    }
View Full Code Here

       
        // First add the entry
        connection.add( entry );
       
        // Check that we can find it back
        EntryCursor cursor = connection.search( "ou=system", "(description=*)", SearchScope.SUBTREE, "*" );

        while ( cursor.next() )
        {
            assertEquals( "ou=testPresence,ou=system", cursor.get().getDn().toString() );
        }
       
        cursor.close();
       
        // Modify the entry to remove the description
        connection.modify( "ou=testPresence,ou=system",
            new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "description" ) );
       
        // Check that we can find it back
        cursor = connection.search( "ou=system", "(description=*)", SearchScope.SUBTREE, "*" );

        while ( cursor.next() )
        {
            fail( "The search should not return any entry" );
        }
       
        cursor.close();
    }
View Full Code Here

        try
        {
            // Retrieve locally the moved or renamed entry
            String filter = "(entryUuid=" + entryUuid + ")";
            EntryCursor cursor = connection.search( Dn.ROOT_DSE, filter, SearchScope.SUBTREE,
                SchemaConstants.ALL_ATTRIBUTES_ARRAY );

            Entry localEntry = cursor.get();

            // Compute the DN, parentDn and Rdn for both entries
            Dn localDn = localEntry.getDn();
            Dn remoteDn = remoteEntry.getDn();
View Full Code Here

     * @throws Exception on error
     */
    @Test
    public void testSystemContextRoot() throws Exception
    {
        EntryCursor responses = connection
            .search( "ou=system", "(objectClass=*)", SearchScope.OBJECT, "*" );
        responses.next();
        Entry entry = responses.get();

        // test to make sure op attribute do not occur - this is the control
        assertNull( entry.get( "creatorsName" ) );
        assertNull( entry.get( "createTimestamp" ) );
       
        responses.close();

        // now we ask for all the op attributes and check to get them
        responses = connection.search( "ou=system", "(objectClass=*)", SearchScope.OBJECT, "creatorsName",
            "createTimestamp" );
        responses.next();
        entry = responses.get();

        assertNotNull( entry.get( "creatorsName" ) );
        assertNotNull( entry.get( "createTimestamp" ) );

        // We should not have any other operational Attribute
        assertNull( entry.get( "entryUuid" ) );
       
        responses.close();
    }
View Full Code Here

     */
    @Test
    public void testAbandonnedRequest() throws Exception
    {
        LdapConnection asyncCnx = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
        EntryCursor cursor = null;
   
        try
        {
            // Use the client API as JNDI cannot be used to do a search without
            // first binding. (hmmm, even client API won't allow searching without binding)
            asyncCnx.bind( "uid=admin,ou=system", "secret" );
   
            // First, add 1000 entries in the server
            for ( int i = 0; i < 1000; i++ )
            {
                String dn = "cn=user" + i + "," + BASE;
                Entry kate = new DefaultEntry( dn );
   
                kate.add( "objectclass", "top", "person" );
                kate.add( "sn", "Bush" );
                kate.add( "cn", "user" + i );
   
                asyncCnx.add( kate );
            }
   
            // Searches for all the entries in ou=system
            cursor = asyncCnx.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" );
   
            // Now loop on all the elements found, and abandon after 10 elements returned
            int count = 0;
   
            while ( cursor.next() )
            {
                count++;
   
                if ( count == 10 )
                {
                    // the message ID = 1 bind op + 1000 add ops + 1 search op
                    asyncCnx.abandon( 1002 );
                }
            }
   
            assertEquals( 10, count );
        }
        catch ( LdapException e )
        {
            e.printStackTrace();
            fail( "Should not have caught exception." );
        }
        finally
        {
            asyncCnx.unBind();
            asyncCnx.close();
            cursor.close();
        }
    }
View Full Code Here

     * @throws Exception on error
     */
    @Test
    public void testFailSearchNoSuchObject() throws Exception
    {
        EntryCursor cursor = getAdminConnection( getService() ).search( "ou=blah", "(objectClass=*)",
            SearchScope.ONELEVEL, "*" );
        assertFalse( cursor.next() );
        cursor.close();
    }
View Full Code Here

     * @throws Exception on error
     */
    @Test
    public void testSearchControl() throws Exception
    {
        EntryCursor cursor = getAdminConnection( getService() ).search( "ou=users,ou=system", "(objectClass=*)",
            SearchScope.ONELEVEL, "*" );

        assertFalse( cursor.next() );

        cursor.close();
    }
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.