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

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


        // Slow down sending of results, otherwise it is possible that the server already sent all results
        // before the abandon request arrives. See DIRAPI-94.
        delayInterceptor.setDelayMillis( 1 );

        // Launch the search now
        EntryCursor cursor = connection.search( new Dn( "ou=system" ), "(cn=*)", SearchScope.ONELEVEL, "*" );

        int count = 0;

        while ( cursor.next() )
        {
            cursor.get();
            count++;

            if ( count > 10 )
            {
                // Abandon the search request
                AbandonRequest abandon = new AbandonRequestImpl( cursor.getMessageId() );
                connection.abandon( abandon );
            }
        }

        cursor.close();

        //System.out.println( "Responses received / expected : " + count + "/" + numEntries );
        assertTrue( numEntries > count );
    }
View Full Code Here


   
        Dn base = new Dn( "ou=tests,ou=system" );
        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();
   
        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();
   
        removeEntryACI( base );
   
        return counter == resultSetSz;
    }
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

        // create the non-admin user
        createUser( "billyd", "billyd" );
   
        // try a search operation which should fail without any ACI
        LdapConnection userCtx = getConnectionAs( "uid=billyd,ou=users,ou=system", "billyd" );
        EntryCursor cursor = userCtx.search( "ou=users,ou=system", "(ObjectClass=*)", SearchScope.SUBTREE,
            "userPassword" );
        int counter = 0;
   
        while ( cursor.next() )
        {
            Entry result = cursor.get();
            results.put( result.getDn().getName(), result );
            counter++;
        }
   
        cursor.close();
   
        assertEquals( 0, counter );
   
        // now add a subentry that enables anyone to search an entry below ou=system
        createAccessControlSubentry( "protectUserPassword",
            "{" +
                "  identificationTag \"protectUserPassword\"," +
                "  precedence 14," +
                "  authenticationLevel none," +
                "  itemOrUserFirst itemFirst: " +
                "  {" +
                "    protectedItems " +
                "    {" +
                "      allAttributeValues { userPassword }" +
                "    }," +
                "    itemPermissions " +
                "    {" +
                "      {" +
                "        userClasses " +
                "        {" +
                "          allUsers " +
                "        }," +
                "        grantsAndDenials { denyBrowse }" +
                "      }," +
                "      {" +
                "        userClasses " +
                "        {" +
                "          thisEntry " +
                "        }," +
                "        grantsAndDenials { grantBrowse }" +
                "      }" +
                "    }" +
                "  }" +
                "}" );
   
        // see if we can now search that tree which we could not before
        // should work now with billyd now that all users are authorized
        userCtx = getConnectionAs( "uid=billyd,ou=users,ou=system", "billyd" );
        cursor = userCtx.search( "ou=users,ou=system", "(ObjectClass=*)", SearchScope.SUBTREE,
            "userPassword" );
        counter = 0;
   
        while ( cursor.next() )
        {
            Entry result = cursor.get();
            results.put( result.getDn().getName(), result );
            counter++;
        }
   
        cursor.close();
    }
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();
            }

            Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );

            SearchRequest searchRequest = new SearchRequestImpl();

            searchRequest.setBase( dn );
            searchRequest.setFilter( "(ObjectClass=*)" );
            searchRequest.setScope( SearchScope.OBJECT );
            searchRequest.addAttributes( "*" );
            searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );

            long t0 = System.currentTimeMillis();
            long t00 = 0L;
            long tt0 = System.currentTimeMillis();
            int nbIterations = 200000;
            int count = 0;

            for ( int j = 0; j < nbIterations; j++ )
            {
                if ( j % 10000 == 0 )
                {
                    long tt1 = System.currentTimeMillis();

                    System.out.println( j + ", " + ( tt1 - tt0 ) );
                    tt0 = tt1;
                }

                if ( j == 50000 )
                {
                    t00 = System.currentTimeMillis();
                }

                long dt0 = System.nanoTime();
                cursor = new EntryCursorImpl( connection.search( searchRequest ) );
                long dt1 = System.nanoTime();

                deltaSearch += Math.abs( dt1 - dt0 );

                while ( cursor.next() )
                {
                    long dt2 = System.nanoTime();
                    cursor.get();
                    count++;
                    long dt3 = System.nanoTime();

                    deltaGet += Math.abs( dt3 - dt2 );
                }

                long dt4 = System.nanoTime();
                cursor.close();
                long dt5 = System.nanoTime();

                deltaClose += Math.abs( dt5 - dt4 );
            }

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( "ou=system", "(ObjectClass=*)",
                SearchScope.ONELEVEL, "*" );

            int i = 0;

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

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

            for ( int j = 0; j < 10000; j++ )
            {
                cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.ONELEVEL, "*" );

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

                cursor.close();
            }

            Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );

            SearchRequest searchRequest = new SearchRequestImpl();

            searchRequest.setBase( dn );
            searchRequest.setFilter( "(ObjectClass=*)" );
            searchRequest.setScope( SearchScope.ONELEVEL );
            searchRequest.addAttributes( "*" );
            searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );

            long t0 = System.currentTimeMillis();
            long t00 = 0L;
            long tt0 = System.currentTimeMillis();
            int nbIterations = 200000;
            int count = 0;

            for ( int j = 0; j < nbIterations; j++ )
            {
                if ( j % 10000 == 0 )
                {
                    long tt1 = System.currentTimeMillis();

                    System.out.println( j + ", " + ( tt1 - tt0 ) );
                    tt0 = tt1;
                }

                if ( j == 50000 )
                {
                    t00 = System.currentTimeMillis();
                }

                cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.ONELEVEL, "*" );

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

                cursor.close();
            }

            long t1 = System.currentTimeMillis();

            Long deltaWarmed = ( t1 - t00 );
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( "ou=system", "(ObjectClass=*)",
                SearchScope.SUBTREE, "*" );

            int i = 0;

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

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

            for ( int j = 0; j < 10000; j++ )
            {
                cursor = connection.search( "ou=system", "(ObjectClass=*)", SearchScope.SUBTREE, "*" );

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

                cursor.close();
            }

            Dn dn = new Dn( getService().getSchemaManager(), "uid=admin,ou=system" );

            SearchRequest searchRequest = new SearchRequestImpl();

            searchRequest.setBase( dn );
            searchRequest.setFilter( "(ObjectClass=*)" );
            searchRequest.setScope( SearchScope.SUBTREE );
            searchRequest.addAttributes( "*" );
            searchRequest.setDerefAliases( AliasDerefMode.DEREF_ALWAYS );

            long t0 = System.currentTimeMillis();
            long t00 = 0L;
            long tt0 = System.currentTimeMillis();
            int nbIterations = 200000;
            int count = 0;

            for ( int j = 0; j < nbIterations; j++ )
            {
                if ( j % 10000 == 0 )
                {
                    long tt1 = System.currentTimeMillis();

                    System.out.println( j + ", " + ( tt1 - tt0 ) );
                    tt0 = tt1;
                }

                if ( j == 50000 )
                {
                    t00 = System.currentTimeMillis();
                }

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

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

                cursor.close();
            }

            long t1 = System.currentTimeMillis();

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

        connection.add( entry );

        assertTrue( session.exists( dn ) );
       
        EntryCursor cursor = connection.search( entry.getDn(), "(objectClass=*)", SearchScope.OBJECT, SchemaConstants.ALL_ATTRIBUTES_ARRAY );
        assertTrue( cursor.next() );
        entry = cursor.get();
       
        cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.OBJECT, SchemaConstants.ALL_ATTRIBUTES_ARRAY );
        assertTrue( cursor.next() );
        Entry contextEntry = cursor.get();
       
        String expectedCsn = entry.get( SchemaConstants.ENTRY_CSN_AT ).getString();
        String contextCsn = contextEntry.get( SchemaConstants.CONTEXT_CSN_AT ).getString();
        assertEquals( expectedCsn, contextCsn );
    }
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

TOP

Related Classes of org.apache.directory.api.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.