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

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


     * 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


     */
    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() );
        }

        return results;
    }
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

        Entry entry1 = null;
        Entry entry2 = null;
        Entry entry3 = null;
       
        long ns0 = System.currentTimeMillis();
        EntryCursor results = connection.search("dc=example,dc=com", "(displayName=1234Awg-Rosli, Awg-Abd-Rahim SMDS-UIA/G/MMO52D)", SearchScope.SUBTREE, "*" );
       
        while ( results.next() )
        {
            entry1 = results.get();
            break;
        }
       
        results.close();
       
        long ns1 = System.currentTimeMillis();
       
        System.out.println( "Delta search : " + ( ns1 - ns0 ) );

        long ns2 = System.currentTimeMillis();
        results = connection.search("dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE, "*" );
               
        while ( results.next() )
        {
            entry2 = results.get();
            break;
        }
        results.close();
        long ns3 = System.currentTimeMillis();
       
        System.out.println( "Delta search substring : " + ( ns3 - ns2 ) );

        long ns4 = System.currentTimeMillis();
        results = connection.search("dc=example,dc=com", "(uid=6789)", SearchScope.SUBTREE, "*" );
               
        while ( results.next() )
        {
            entry3 = results.get();
            break;
        }
       
        results.close();
        long ns5 = System.currentTimeMillis();
       
        System.out.println( "Delta search no index : " + ( ns5 - ns4 ) );

        System.out.println( "Entry 1 : " + entry1 );
        System.out.println( "Entry 2 : " + entry2 );
        System.out.println( "Entry 3 : " + entry3 );
        connection.close();
       
        // Now, shutdown and restart the server once more
        getService().shutdown();
        getService().startup();
       
        // and do a search again
        connection = (LdapNetworkConnection)LdapApiIntegrationUtils.getPooledAdminConnection( getLdapServer() );

        long ns6 = System.currentTimeMillis();
        results = connection.search("dc=example,dc=com", "(displayName=3456*)", SearchScope.SUBTREE, "*" );
               
        while ( results.next() )
        {
            entry3 = results.get();
            break;
        }
       
        results.close();
        long ns7 = System.currentTimeMillis();
        System.out.println( "New Delta search substring : " + ( ns7 - ns6 ) );

        connection.close();
    }
View Full Code Here

            "employeeNumber: A-A-R.Awg-Rosli",
            "pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" );

        connection.add( entry );
       
        EntryCursor results = connection.search("dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE, "*" );
       
        while ( results.next() )
        {
            Entry result = results.get();
            assertTrue( result.contains( "displayName", "1Awg-Rosli" ) );
        }
       
        results.close();
       
        // Now, modify it
        connection.modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, "displayName", "test" ) );
       
        results = connection.search("dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE, "*" );
       
        while ( results.next() )
        {
            Entry result = results.get();
            assertTrue( result.contains( "displayName", "test" ) );
        }
       
        results.close();

        results = connection.search("dc=example,dc=com", "(displayName=1*)", SearchScope.SUBTREE, "*" );
       
        assertFalse( results.next() );
       
        results.close();
    }
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

            connection.add( entry );
        }

        // 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

    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

   
   
    @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

   
   
    @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

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.