Package org.apache.directory.ldap.client.api

Examples of org.apache.directory.ldap.client.api.LdapConnection



    @Test
    public void testCsnLessEqualitySearch() throws Exception
    {
        LdapConnection connection = IntegrationUtils.getAdminConnection( getService() );

        Dn dn = new Dn( "cn=testLowerCsnAdd,ou=system" );
        Entry entry = new DefaultEntry( dn );
        entry.add( "objectClass", SchemaConstants.PERSON_OC );
        entry.add( "cn", "testLowerCsnAdd_cn" );
        entry.add( "sn", "testLowerCsnAdd_sn" );

        connection.add( entry );

        // add an entry to have a entry with higher CSN value
        Dn dn2 = new Dn( "cn=testHigherCsnAdd,ou=system" );
        Entry entry2 = new DefaultEntry( dn2,
            "objectClass :person",
            "cn: testHigherCsnAdd_cn",
            "sn: testHigherCsnAdd_sn" );

        connection.add( entry2 );

        entry = connection.lookup( dn.getName(), "+" );
        entry2 = connection.lookup( dn2.getName(), "+" );

        String lowerCsn = entry.get( "entryCsn" ).getString();
        String higherCsn = entry2.get( "entryCsn" ).getString();

        // usecases
View Full Code Here


    }


    public static LdapConnection getClientApiConnection( LdapServer ldapServer ) throws Exception
    {
        LdapConnection conn = new LdapConnection( "localhost", ldapServer.getPort() );
        conn.bind( ServerDNConstants.ADMIN_SYSTEM_DN, "secret" );
        return conn;
    }
View Full Code Here

            int port = config.getPort();

            // Create a connection
            if ( connection == null )
            {
                connection = new LdapConnection( providerHost, port );
            }

            // Do a bind
            BindResponse bindResponse = connection.bind( config.getBindDn(), config.getCredentials() );
View Full Code Here

    private static final Logger LOG = LoggerFactory.getLogger( EntryInjector.class );


    public EntryInjector( String host, int port, String bindDn, String pwd ) throws Exception
    {
        connection = new LdapConnection( host, port );
        connection.bind( bindDn, pwd );

        addcomponents();
    }
View Full Code Here

    private static final String DN = "cn=Kate Bush,ou=system";

    @Test
    public void testIllegalModification() throws Exception
    {
        LdapConnection con = getClientApiConnection( ldapServer );

        ModifyRequest modReq = new ModifyRequest( new DN( DN ) );
        modReq.add( "description", "" );

        ModifyResponse resp = con.modify( modReq );
        assertEquals( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, resp.getLdapResult().getResultCode() );

        // Check whether entry is unmodified, i.e. no description
        Entry entry = ( ( SearchResultEntry )con.lookup( DN ) ).getEntry();
        assertEquals( "description exists?", null, entry.get( "description" ) );
    }
View Full Code Here

     * the ManageDsaIT control.
     */
    @Test
    public void testNormalDeleteFailContextNotEmpty() throws Exception
    {
        LdapConnection conn = getClientApiConnection( ldapServer );
       
        // delete failure on non-leaf entry
        DeleteResponse resp = conn.delete( "uid=akarasulu,ou=users,ou=system" );
        assertEquals( ResultCodeEnum.NOT_ALLOWED_ON_NON_LEAF, resp.getLdapResult().getResultCode() );

        conn.unBind();
    }
View Full Code Here

     * the ManageDsaIT control.
     */
    @Test
    public void testNormalDelete() throws Exception
    {
        LdapConnection conn = getClientApiConnection( ldapServer );
       
        // delete success
        conn.delete( "ou=computers,uid=akarasulu,ou=users,ou=system" );

        // delete failure non-existant entry
        DeleteResponse resp = conn.delete( "uid=elecharny,ou=users,ou=system" );
        assertEquals( ResultCodeEnum.NO_SUCH_OBJECT, resp.getLdapResult().getResultCode() );
       
        conn.unBind();
    }
View Full Code Here

     * the ManageDsaIT control.
     */
    @Test
    public void testDeleteNonExistent() throws Exception
    {
        LdapConnection conn = getClientApiConnection( ldapServer );
       
        // delete failure non-existent entry
        DeleteResponse resp = conn.delete( "uid=elecharny,ou=users,ou=system" );
        assertEquals( ResultCodeEnum.NO_SUCH_OBJECT, resp.getLdapResult().getResultCode() );
       
        conn.unBind();
    }
View Full Code Here

     * during parsing the given DN
     */
    @Test
    public void testDeleteWithIllegalName() throws Exception
    {
        LdapConnection conn = getClientApiConnection( ldapServer );
       
        try
        {
            conn.delete("This is an illegal name,dc=example,dc=com" );
            fail( "deletion should fail" );
        }
        catch ( LdapException e )
        {
            // expected
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testBindRequest()
    {
        LdapConnection connection = null;
        try
        {
            connection = new LdapConnection( config );
            BindResponse bindResponse = connection.bind( "uid=admin,ou=system", "secret" );
           
            assertNotNull( bindResponse );
           
            connection.unBind();
        }
        catch ( Exception le )
        {
            le.printStackTrace();
            fail();
View Full Code Here

TOP

Related Classes of org.apache.directory.ldap.client.api.LdapConnection

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.