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

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


        Dn base = addSearchData( new Dn( "ou=system" ), 3, 10 );
        Dn userDn = new Dn( "uid=" + uid + ",ou=users,ou=system" );
        results.clear();
        LdapConnection userCtx = getConnectionAs( userDn, password );
        EntryCursor cursor = userCtx.search( base.getName(), filter, scope, "*" );
        int counter = 0;

        while ( cursor.next() )
        {
            Entry result = cursor.get();
            results.put( result.getDn().getName(), result );
            counter++;
        }

        cursor.close();

        recursivelyDelete( base );

        return counter == resultSetSz;
    }
View Full Code Here


        addEntryACI( base, aci );
        Dn userDn = new Dn( "uid=" + uid + ",ou=users,ou=system" );

        results.clear();
        LdapConnection userCtx = getConnectionAs( userDn, password );
        EntryCursor cursor = userCtx.search( base.getName(), "(objectClass=*)", scope, "*" );
        int counter = 0;

        while ( cursor.next() )
        {
            Entry result = cursor.get();
            results.put( result.getDn().getName(), result );
            counter++;
        }

        cursor.close();

        recursivelyDelete( base );

        return counter == resultSetSz;
    }
View Full Code Here

    public void testAddSearchData() throws Exception
    {
        LdapConnection connection = getAdminConnection();
        Dn base = addSearchData( new Dn( "ou=system" ), 3, 10 );

        EntryCursor entries = connection.search( base.getName(), "(objectClass=*)", SearchScope.SUBTREE,
            "+" );
        int counter = 0;

        while ( entries.next() )
        {
            entries.get();
            counter++;
        }

        entries.close();

        assertEquals( 10, counter );
        recursivelyDelete( base );

        Entry entry = connection.lookup( base.getName() );
View Full Code Here

     */
    private Entry checkCanSearchSubentryAs( String uid, String password, Dn dn ) throws Exception
    {
        LdapConnection userCtx = getConnectionAs( new Dn( "uid=" + uid + ",ou=users,ou=system" ), password );
        Entry result = null;
        EntryCursor list = null;

        list = userCtx.search( dn.getName(), "(objectClass=*)", SearchScope.OBJECT, "*" );

        if ( list.next() )
        {
            result = list.get();
        }

        list.close();

        return result;
    }
View Full Code Here

    {
        LdapConnection connection = getAdminConnection();

        HashSet<String> set = new HashSet<String>();

        EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "*" );

        while ( cursor.next() )
        {
            Entry result = cursor.get();
            set.add( result.getDn().getName() );
        }

        cursor.close();

        assertEquals( 10, set.size() );
        assertTrue( set.contains( "ou=system" ) );
        assertTrue( set.contains( "ou=configuration,ou=system" ) );
        assertTrue( set.contains( "ou=interceptors,ou=configuration,ou=system" ) );
View Full Code Here

     * fetches the rootDSE from the server
     * @throws LdapException
     */
    private void fetchRootDSE() throws LdapException
    {
        EntryCursor cursor = null;

        try
        {
            cursor = search( "", "(objectClass=*)", SearchScope.OBJECT, "*", "+" );
            cursor.next();
            rootDSE = cursor.get();
        }
        catch ( Exception e )
        {
            String msg = "Failed to fetch the RootDSE";
            LOG.error( msg );
            throw new LdapException( msg, e );
        }
        finally
        {
            if ( cursor != null )
            {
                try
                {
                    cursor.close();
                }
                catch ( Exception e )
                {
                    LOG.error( "Failed to close open cursor", e );
                }
View Full Code Here

        List<Dn> present = new ArrayList<Dn>();
       
        int connectionIndex = rand.nextInt( connections.size() );

        LdapNetworkConnection nc = connections.get( connectionIndex );
        EntryCursor cursor = nc.search( containerDn, "(cn=" + RDN_PREFIX + "*)", SearchScope.ONELEVEL, SchemaConstants.NO_ATTRIBUTE_ARRAY );
       
        while( cursor.next() )
        {
            present.add( cursor.get().getDn() );
        }
       
        cursor.close();
       
        for( int i=0; i < present.size(); i++ )
        {
            connectionIndex = rand.nextInt( connections.size() );
            nc = connections.get( connectionIndex );
View Full Code Here

            // 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)
            connection.bind( "uid=admin,ou=system", "secret" );

            // Searches for all the entries in ou=system
            EntryCursor cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)",
                SearchScope.OBJECT, "*" );

            int i = 0;

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

            cursor.close();
            assertEquals( 1, i );

            for ( int j = 0; j < 10000; j++ )
            {
                cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)", SearchScope.OBJECT, "*" );
               
                while ( cursor.next() )
                {
                }
               
                cursor.close();
            }

            long t0 = System.currentTimeMillis();
            int nbIterations = 200000;

            for ( int j = 0; j < nbIterations; j++ )
            {
                if ( j % 10000 == 0 )
                {
                    System.out.println( j );
                }

                cursor = connection.search( "uid=admin,ou=system", "(ObjectClass=*)", SearchScope.OBJECT, "*" );
                while ( cursor.next() )
                {
                }
                cursor.close();
            }

            long t1 = System.currentTimeMillis();

            Long deltaWarmed = ( t1 - t0 );
View Full Code Here


    @Test
    public void testSimpleSearch() throws Exception
    {
        EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL );
        int count = 0;
       
        while ( cursor.next() )
        {
            Entry entry = cursor.get();
            assertNotNull( entry );
            count++;
        }

        SearchResultDone done = cursor.getSearchResultDone();

        assertNotNull( done );
        assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
        assertEquals( 5, count );
        cursor.close();
    }
View Full Code Here

    @Test
    public void testSimpleSearchWithControl() throws Exception
    {
        SearchRequest searchRequest = new SearchRequestImpl().setBase( new Dn( "ou=system" ) ).setFilter( "(objectclass=*)" )
        .setScope( SearchScope.ONELEVEL ).addControl( new ManageDsaITImpl() );
        EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)", SearchScope.ONELEVEL );
        int count = 0;
       
        while ( cursor.next() )
        {
            Entry entry = cursor.get();
            assertNotNull( entry );
            count++;
        }

        SearchResultDone done = cursor.getSearchResultDone();

        assertNotNull( done );
        assertEquals( ResultCodeEnum.SUCCESS, done.getLdapResult().getResultCode() );
        assertEquals( 5, count );
        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.