Examples of EntryCursor


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

   
    @Test
    public void testSubDn() throws Exception
    {
        connection.loadSchema();
        EntryCursor cursor = connection.search( "ou=system", "(cn=user1)", SearchScope.SUBTREE, "publicKey" );
   
        assertTrue( cursor.next() );
   
        Entry entry = cursor.get();
        assertEquals( "cn=user1,ou=users,ou=system", entry.getDn().getName() );
   
        cursor.close();
   
        SearchRequest req = new SearchRequestImpl();
        req.setScope( SearchScope.SUBTREE );
        req.addAttributes( "*" );
        req.setTimeLimit( 0 );
View Full Code Here

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

        while ( true )
        {
            loop++;

            EntryCursor cursor = null;

            try
            {
                SearchRequest searchRequest = new SearchRequestImpl();
                searchRequest.setBase( new Dn( "ou=system" ) );
                searchRequest.setFilter( "(ObjectClass=*)" );
                searchRequest.setScope( SearchScope.SUBTREE );
                searchRequest.addAttributes( "*" );
                searchRequest.addControl( pagedSearchControl );

                cursor = new EntryCursorImpl( connection.search( searchRequest ) );

                int i = 0;

                while ( cursor.next() )
                {
                    Entry result = cursor.get();
                    results.add( result );
                    ++i;
                }

                SearchResultDone result = cursor.getSearchResultDone();
                pagedSearchControl = ( PagedResults ) result.getControl( PagedResults.OID );

                if ( result.getLdapResult().getResultCode() == ResultCodeEnum.UNWILLING_TO_PERFORM )
                {
                    hasUnwillingToPerform = true;
                    break;
                }
            }
            finally
            {
                if ( cursor != null )
                {
                    cursor.close();
                }
            }

            // Now read the next ones
            assertEquals( 0, pagedSearchControl.getSize() );
View Full Code Here

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


@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( 4, count );
    cursor.close();
}
View Full Code Here

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


@Test
public void testSearch() throws Exception
{
    EntryCursor cursor = connection.search( "ou=system", "(objectclass=*)",
        SearchScope.ONELEVEL,
        "*", "+" );
    int count = 0;

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

    SearchResultDone done = cursor.getSearchResultDone();

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

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


@Test
public void testSearchEquality() throws Exception
{
    EntryCursor cursor = connection.search( "ou=system", "(objectclass=organizationalUnit)",
        SearchScope.ONELEVEL, "*", "+" );
    int count = 0;

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

    assertEquals( 2, count );
    cursor.close();
}
View Full Code Here

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


@Test
public void testSearchUTF8() throws Exception
{
    EntryCursor cursor = connection.search( "ou=system", "(sn=Emmanuel L\u00E9charny)", SearchScope.ONELEVEL,
        "*", "+" );

    assertTrue( cursor.next() );

    Entry entry = cursor.get();
    assertNotNull( entry );
    assertTrue( entry.contains( "cn", "elecharny" ) );
    assertTrue( entry.contains( "sn", "Emmanuel L\u00E9charny" ) );

    cursor.close();
}
View Full Code Here

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

@Test
public void testSearchBinary() throws Exception
{
    connection.loadSchema();
    EntryCursor cursor = connection
        .search(
            "ou=system",
            "(publicKey=\\30\\5C\\30\\0D\\06\\09\\2A\\86\\48\\86\\F7\\0D\\01\\01\\01\\05\\00\\03\\4B\\00\\30\\48\\02\\41\\00\\A6\\C7\\9C\\B1\\6C\\E4\\DD\\8F\\1E\\4D\\20\\93\\22\\3F\\83\\75\\DE\\21\\D8\\F1\\9D\\63\\80\\5B\\94\\55\\6A\\9E\\33\\59\\9B\\8D\\63\\88\\0D\\18\\7D\\4C\\85\\F1\\CF\\54\\77\\32\\E9\\61\\0C\\A2\\8F\\B3\\6B\\15\\34\\5E\\1F\\88\\BF\\A0\\73\\AC\\86\\BB\\D0\\85\\02\\03\\01\\00\\01)",
            SearchScope.SUBTREE, "publicKey" );

    assertTrue( cursor.next() );

    Entry entry = cursor.get();
    assertNotNull( entry.get( "publicKey" ) );

    cursor.close();
}
View Full Code Here

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

@Test
public void testSubDn() throws Exception
{
    connection.loadSchema();
    EntryCursor cursor = connection.search( "ou=system", "(cn=user1)", SearchScope.SUBTREE, "publicKey" );

    assertTrue( cursor.next() );

    Entry entry = cursor.get();
    assertEquals( "cn=user1,ou=system", entry.getDn().getName() );

    cursor.close();

    SearchRequest req = new SearchRequestImpl();
    req.setScope( SearchScope.SUBTREE );
    req.addAttributes( "*" );
    req.setTimeLimit( 0 );
    req.setBase( new Dn( "ou=system" ) );
    req.setFilter( "(cn=user1)" );

    SearchCursor searchCursor = connection.search( req );

    assertTrue( searchCursor.next() );

    Response response = searchCursor.get();

    Entry resultEntry = ( ( SearchResultEntry ) response ).getEntry();
    assertEquals( "cn=user1,ou=system", resultEntry.getDn().getName() );

    cursor.close();
}
View Full Code Here

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

        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

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

        for ( int i = 0; i < 100; i++ )
        {
            try
            {
                EntryCursor results = connection.search( "dc=example,dc=com", "(cn=*)", SearchScope.SUBTREE, "*" );

                int nbFound = 0;

                while ( results.next() && ( nbFound < 1000 ) )
                {
                    Entry result = results.get();
                    nbFound++;
                }

                System.out.println( "Running " + i + "th search, getting back " + nbFound
                    + " entries, nb added entries : " + nbAdded );

                results.close();

                if ( nbAdded >= 10000 )
                {
                    break;
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.