Package netscape.ldap

Examples of netscape.ldap.LDAPConnection


     * Tests ModifyDN operation on referral entry with the ManageDsaIT control.
     */
    @Test
    public void testOnReferralWithManageDsaITControl() throws Exception
    {
        LDAPConnection conn = getWiredConnection( ldapServer );
        LDAPConstraints constraints = new LDAPSearchConstraints();
        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
        conn.setConstraints( constraints );
       
        // ModifyDN success
        conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints );
        LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
        assertNotNull( entry );
        assertEquals( "uid=ref,ou=users,ou=system", entry.getDN() );
       
        conn.disconnect();
    }
View Full Code Here


     * ManageDsaIT control.
     */
    @Test
    public void testNewSuperiorOnReferralWithManageDsaITControl() throws Exception
    {
        LDAPConnection conn = getWiredConnection( ldapServer );
        LDAPConstraints constraints = new LDAPSearchConstraints();
        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, new byte[0] ) );
        conn.setConstraints( constraints );
       
        // ModifyDN success
        try
        {
            conn.rename( "uid=elecharny,ou=users,ou=system", "uid=newuser",
                "uid=akarasuluref,ou=users,ou=system", true, constraints );
        }
        catch ( LDAPException le )
        {
            assertEquals ( LDAPException.AFFECTS_MULTIPLE_DSAS, le.getLDAPResultCode() );
        }
       
        conn.disconnect();
    }
View Full Code Here

     * non-success result code.
     */
    @Test
    public void testOnReferral() throws Exception
    {
        LDAPConnection conn = getWiredConnection( ldapServer );
        LDAPConstraints constraints = new LDAPConstraints();
        constraints.setReferrals( false );
        conn.setConstraints( constraints );
       
        // referrals failure
        LDAPResponseListener listener = null;
        LDAPResponse response = null;

        listener = conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, null, constraints );
        response = listener.getResponse();
        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );

        assertEquals( "ldap://localhost:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
        assertEquals( "ldap://foo:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
        assertEquals( "ldap://bar:10389/uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );

        conn.disconnect();
    }
View Full Code Here

     * non-success result code.
     */
    @Test
    public void testNewSupierorOnReferral() throws Exception
    {
        LDAPConnection conn = getWiredConnection( ldapServer );
        LDAPConstraints constraints = new LDAPConstraints();
        constraints.setReferrals( false );
        conn.setConstraints( constraints );
       
        // referrals failure
        try
        {
            conn.rename( "uid=elecharny,ou=users,ou=system", "uid=ref",
                "uid=akarasuluref,ou=users,ou=system", true, constraints );
        }
        catch ( LDAPException e )
        {
            assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
        }

        conn.disconnect();
    }
View Full Code Here

    @Test
    public void testAncestorReferral() throws Exception
    {
        LOG.debug( "" );

        LDAPConnection conn = getWiredConnection( ldapServer );
        LDAPConstraints constraints = new LDAPConstraints();
        conn.setConstraints( constraints );

        // referrals failure
        LDAPResponseListener listener = null;
        LDAPResponse response = null;

        listener = conn.rename( "ou=Computers,uid=akarasuluref,ou=users,ou=system", "ou=Machines", true, null, constraints );
        response = listener.getResponse();
        assertEquals( ResultCodeEnum.REFERRAL.getValue(), response.getResultCode() );

        assertEquals( "ldap://localhost:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[0] );
        assertEquals( "ldap://foo:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[1] );
        assertEquals( "ldap://bar:10389/ou=Computers,uid=akarasulu,ou=users,ou=system", response.getReferrals()[2] );

        conn.disconnect();
    }
View Full Code Here

    @Test
    public void testNewSuperiorAncestorReferral() throws Exception
    {
        LOG.debug( "" );

        LDAPConnection conn = getWiredConnection( ldapServer );
        LDAPConstraints constraints = new LDAPConstraints();
        conn.setConstraints( constraints );

        // referrals failure
        try
        {
            conn.rename( "uid=elecharny,ou=users,ou=system", "ou=Machines",
                "ou=Computers,uid=akarasuluref,ou=users,ou=system", true, constraints );
            fail( "Should never get here to affectsMultipleDSA error result code" );
        }
        catch ( LDAPException e )
        {
            assertEquals( LDAPException.AFFECTS_MULTIPLE_DSAS, e.getLDAPResultCode() );
        }

        conn.disconnect();
    }
View Full Code Here


    @Test
    public void testConnectWithIllegalLDAPVersion() throws Exception
    {
        LDAPConnection conn = null;

        try
        {
            conn = new LDAPConnection();
            conn.connect( 100, "localhost", getLdapServer().getPort(), "uid=admin,ou=system", "secret" );
            fail( "try to connect with illegal version number should fail" );
        }
        catch ( LDAPException e )
        {
            assertEquals( "statuscode", LDAPException.PROTOCOL_ERROR, e.getLDAPResultCode() );
        }
        finally
        {
            if ( conn != null )
            {
                conn.disconnect();
            }
        }
    }
View Full Code Here

     * Tests bind operation on referral entry.
     */
    @Test
    public void testOnReferralWithOrWithoutManageDsaItControl() throws Exception
    {
        LDAPConnection conn = new LDAPConnection();
        LDAPConstraints constraints = new LDAPConstraints();
        constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
        constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
        conn.setConstraints( constraints );

        try
        {
            conn.connect( 3, "localhost", getLdapServer().getPort(),
                "uid=akarasuluref,ou=users,ou=system", "secret", constraints );
            fail( "try to connect with illegal version number should fail" );
        }
        catch ( LDAPException e )
        {
            assertEquals( "statuscode", LDAPException.INVALID_CREDENTIALS, e.getLDAPResultCode() );
        }

        try
        {
            conn.connect( 3, "localhost", getLdapServer().getPort(),
                "uid=akarasuluref,ou=users,ou=system", "secret" );
            fail( "try to connect with illegal version number should fail" );
        }
        catch ( LDAPException e )
        {
View Full Code Here


    @Test
    public void testIllegalModification2() throws Exception
    {
        LDAPConnection con = getNsdkWiredConnection( getLdapServer() );

        // first a valid attribute
        LDAPAttribute attr = new LDAPAttribute( "description", "The description" );
        LDAPModification mod = new LDAPModification( LDAPModification.ADD, attr );
        // then an invalid one without any value
        attr = new LDAPAttribute( "displayName" );
        LDAPModification mod2 = new LDAPModification( LDAPModification.ADD, attr );

        try
        {
            con.modify( "cn=Kate Bush,ou=system", new LDAPModification[]
                { mod, mod2 } );
            fail( "error expected due to empty attribute value" );
        }
        catch ( LDAPException e )
        {
            // expected
        }

        // Check whether entry is unmodified, i.e. no displayName
        LDAPEntry entry = con.read( DN );
        assertEquals( "displayName exists?", null, entry.getAttribute( "displayName" ) );
    }
View Full Code Here

* Tests ModifyDN operation on referral entry with the ManageDsaIT control.
*/
@Test
public void testOnReferralWithManageDsaITControl() throws Exception
{
    LDAPConnection conn = getNsdkWiredConnection( getLdapServer() );
    LDAPConstraints constraints = new LDAPSearchConstraints();
    constraints.setClientControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
    constraints.setServerControls( new LDAPControl( LDAPControl.MANAGEDSAIT, true, Strings.EMPTY_BYTES ) );
    conn.setConstraints( constraints );

    // ModifyDN success
    conn.rename( "uid=akarasuluref,ou=users,ou=system", "uid=ref", true, constraints );
    LDAPEntry entry = conn.read( "uid=ref,ou=users,ou=system", ( LDAPSearchConstraints ) constraints );
    assertNotNull( entry );
    assertEquals( "uid=ref,ou=users,ou=system", entry.getDN() );

    conn.disconnect();
}
View Full Code Here

TOP

Related Classes of netscape.ldap.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.