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

Examples of org.apache.directory.ldap.client.api.LdapConnection.bind()


        BindRequest bindReq = new BindRequestImpl();
        bindReq.setCredentials( "secret" );
        bindReq.setName( userDn );
        bindReq.setSaslMechanism( SupportedSaslMechanisms.PLAIN );

        BindResponse resp = connection.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, resp.getLdapResult().getResultCode() );

        Entry entry = connection.lookup( userDn );
        assertEquals( "hnelson", entry.get( "uid" ).getString() );
View Full Code Here


        bindReq.setSaslMechanism( "" ); // invalid mechanism
        bindReq.setSimple( false );

        try
        {
            connection.bind( bindReq );
            fail();
        }
        catch ( LdapException le )
        {
            //expected
View Full Code Here

        assertFalse( connection.isConnected() );
        connection.close();

        // Try with empty strings
        connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
        connection.bind( "", "" );

        assertTrue( connection.isAuthenticated() );

        connection.unBind();
        assertFalse( connection.isConnected() );
View Full Code Here

        assertFalse( connection.isConnected() );
        connection.close();

        // Try with null parameters
        connection = new LdapNetworkConnection( "localhost", getLdapServer().getPort() );
        connection.bind( ( String ) null, ( String ) null );

        assertTrue( connection.isAuthenticated() );
        assertTrue( connection.isConnected() );

        connection.unBind();
View Full Code Here


    public static LdapConnection getConnectionAs( String host, int port, String dn, String password ) throws Exception
    {
        LdapConnection connection = new LdapConnection( host, port );
        connection.bind( dn, password );
        openConnections.add( connection );
        return connection;
    }
   
   
View Full Code Here

       
        LdapConnection userConnection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );

        for( int i=0; i< 3; i++ )
        {
            userConnection.bind( bindReq );
            assertFalse( userConnection.isAuthenticated() );
        }
       
        // Added an extra wait (for Windows)
        Thread.sleep( 2000 );
View Full Code Here

       
        bindReq = new BindRequestImpl();
        bindReq.setDn( userDn );
        bindReq.setCredentials( "12345" ); // correct password
        bindReq.addControl( PP_REQ_CTRL );
        userConnection.bind( bindReq );
        assertFalse( userConnection.isAuthenticated() ); // but still fails cause account is locked
       
        userConnection.close();
       
        // test deleting the password, it should clear all the ppolicy related attributes except the ppolicy subentry
View Full Code Here

        LdapConnection userCon= new LdapNetworkConnection( "localhost", ldapServer.getPort() );
        userCon.setTimeOut(0);

        Thread.sleep( 1000 ); // sleep for one second so that the password expire warning will be sent
       
        BindResponse bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
       
        PasswordPolicy respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );
View Full Code Here

        assertTrue( respCtrl.getResponse().getTimeBeforeExpiration() > 0 );
       
        Thread.sleep( 4000 ); // sleep for four seconds so that the password expires
       
        // bind for two more times, should succeed
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertNotNull( respCtrl );
        assertEquals( 1, respCtrl.getResponse().getGraceAuthNsRemaining() );
       
View Full Code Here

        assertNotNull( respCtrl );
        assertEquals( 1, respCtrl.getResponse().getGraceAuthNsRemaining() );
       
        // this extra second sleep is necessary to modify pwdGraceUseTime attribute with a different timestamp
        Thread.sleep( 1000 );
        bindResp = userCon.bind( bindReq );
        assertEquals( ResultCodeEnum.SUCCESS, bindResp.getLdapResult().getResultCode() );
        respCtrl = getPwdRespCtrl( bindResp );
        assertEquals( 0, respCtrl.getResponse().getGraceAuthNsRemaining() );
       
        // this time it should fail
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.