@Ignore("Activate when DIRAPI-30 is solved")
@Test
public void testSequentialBinds() throws Exception
{
LdapNetworkConnection connection;
BindResponse resp;
Entry entry;
Dn userDn = new Dn( "uid=hnelson,ou=users,dc=example,dc=com" );
for ( int i = 0; i < 1000; i++ )
{
System.out.println( "try " + i );
// Digest-MD5
connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
DigestMd5Request digetDigestMd5Request = new DigestMd5Request();
digetDigestMd5Request.setUsername( userDn.getRdn().getValue().getString() );
digetDigestMd5Request.setCredentials( "secret" );
digetDigestMd5Request.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
resp = connection.bind( digetDigestMd5Request );
assertEquals( ResultCodeEnum.SUCCESS, resp.getLdapResult().getResultCode() );
entry = connection.lookup( userDn );
assertEquals( "hnelson", entry.get( "uid" ).getString() );
connection.close();
// Cram-MD5
connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
CramMd5Request cramMd5Request = new CramMd5Request();
cramMd5Request.setUsername( userDn.getRdn().getValue().getString() );
cramMd5Request.setCredentials( "secret" );
resp = connection.bind( cramMd5Request );
assertEquals( ResultCodeEnum.SUCCESS, resp.getLdapResult().getResultCode() );
entry = connection.lookup( userDn );
assertEquals( "hnelson", entry.get( "uid" ).getString() );
connection.close();
// GSSAPI
connection = new LdapNetworkConnection( "localhost", ldapServer.getPort() );
GssApiRequest gssApiRequest = new GssApiRequest();
gssApiRequest.setUsername( userDn.getRdn().getValue().getString() );
gssApiRequest.setCredentials( "secret" );
gssApiRequest.setRealmName( ldapServer.getSaslRealms().get( 0 ) );
gssApiRequest.setKdcHost( "localhost" );
gssApiRequest.setKdcPort( 6088 );
resp = connection.bind( gssApiRequest );
assertEquals( ResultCodeEnum.SUCCESS, resp.getLdapResult().getResultCode() );
entry = connection.lookup( userDn );
assertEquals( "hnelson", entry.get( "uid" ).getString() );
connection.close();
}
}