Examples of EntryCursor


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

            "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" );

        connection.add( entry );

        // Check the search using the cn index
        EntryCursor results = connection.search( "dc=example,dc=com", "(cn=e*)", SearchScope.SUBTREE, "*" );

        int nbFound = 0;

        while ( results.next() )
        {
            Entry result = results.get();
            assertTrue( result.contains( "cn", "entryTest" ) );
            nbFound++;
        }

        results.close();

        assertEquals( 1, nbFound );

        // Ok, now replace the cn
        Modification modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, "displayName",
            "testEntry" );

        connection.modify( dn, modification );

        // We should not find anything using the substring filter for the displayName AT
        results = connection.search( "dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE, "*" );

        assertFalse( results.next() );

        results.close();

        // Check that we cannot find the displayName using the presence index
        results = connection.search( "dc=example,dc=com", "(displayName=n*)", SearchScope.SUBTREE, "*" );

        assertFalse( results.next() );

        results.close();

        // Now, Delete one value from the cn index
        modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, "cn", "test2" );

        connection.modify( dn, modification );

        // Check the cn index using the remaining value
        results = connection.search( "dc=example,dc=com", "(cn=E*)", SearchScope.SUBTREE, "*" );

        nbFound = 0;

        while ( results.next() )
        {
            Entry result = results.get();
            assertFalse( result.contains( "cn", "test2" ) );
            assertTrue( result.contains( "cn", "entryTest" ) );
            nbFound++;
        }

        assertEquals( 1, nbFound );

        results.close();

        // Check the cn index using the removed value
        results = connection.search( "dc=example,dc=com", "(cn=t*)", SearchScope.SUBTREE, "*" );

        assertFalse( results.next() );

        results.close();

        // Now, check the presence index
        results = connection.search( "dc=example,dc=com", "(cn=*)", SearchScope.SUBTREE, "*" );

        nbFound = 0;

        while ( results.next() )
        {
            Entry result = results.get();
            assertFalse( result.contains( "cn", "test2" ) );
            assertTrue( result.contains( "cn", "entryTest" ) );
            nbFound++;
        }

        assertEquals( 1, nbFound );

        results.close();

        // Delete the entry
        connection.delete( dn );
    }
View Full Code Here

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

        }

        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

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

    @Test
    public void testNotEvaluator() throws Exception
    {
        LdapConnection con = new LdapCoreSessionConnection( service.getAdminSession() );

        EntryCursor cursor = con.search( "ou=groups,ou=system", "(!(gidNumber=00001))", SearchScope.ONELEVEL, SchemaConstants.ALL_ATTRIBUTES_ARRAY );

        int count = 0;
        while ( cursor.next() )
        {
            count++;
        }
       
        cursor.close();
       
        assertEquals( 5, count );
    }
View Full Code Here

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

    @Test
    public void testSearchRootDSEOneLevel() throws Exception
    {
        LdapConnection conn = getAdminConnection( service );

        EntryCursor cursor = conn.search( "ou=schema", "(|(objectClass=*)(cn=x))", SearchScope.OBJECT, "*" );

        assertTrue( cursor.next() );
        cursor.close();

        cursor = conn.search( "ou=schema", "(objectClass=person)", SearchScope.OBJECT, "*" );

        assertFalse( cursor.next() );
        cursor.close();

        cursor = conn.search( "", "(objectClass=person)", SearchScope.ONELEVEL, "*" );

        assertFalse( cursor.next() );
        cursor.close();
       
        cursor = conn.search( "", "(objectClass=person)", SearchScope.SUBTREE, "*" );
        int count = 0;
        while( cursor.next() )
        {
            count++;
        }
       
        assertEquals(3, count);
        cursor.close();
    }
View Full Code Here

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

     */
    @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 100 entries in the server
            for ( int i = 0; i < 100; 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 + 100 add ops + 1 search op
                    asyncCnx.abandon( 102 );
                }
            }

            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

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

     * "c=usa, ou=system", and ask for a subtree search
     */
    @Test
    public void testSearchWithReferralThrow() throws Exception
    {
        EntryCursor cursor = connection.search( "ou=Countries,ou=system", "(objectClass=*)",
            SearchScope.SUBTREE, "*", "+" );
        int count = 0;
        Entry entry = null;
        List<String> refs = new ArrayList<String>();
   
        while ( cursor.next() )
        {
            try
            {
                entry = cursor.get();
   
                assertNotNull( entry );
                count++;
            }
            catch ( CursorLdapReferralException clre )
            {
                count++;
   
                do
                {
                    String ref = clre.getReferralInfo();
                    refs.add( ref );
                }
                while ( clre.skipReferral() );
            }
        }
   
        assertEquals( 3, count );
        assertEquals( 2, refs.size() );
        assertTrue( refs.contains( "ldap://localhost:52489/c=usa,ou=system??sub" ) );
        assertTrue( refs.contains( "ldap://localhost:52489/c=france,ou=system??sub" ) );
        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( 5, 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( 4, 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=users,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
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.