"pwdPolicySubEntry: ads-pwdId=cproint,ou=passwordPolicies,ads-interceptorId=authenticationInterceptor,ou=interceptors,ads-directoryServiceId=default,ou=config" );
connection.add( entry );
// Check the search using the cn index
EntryCursor results = connection.search( "dc=example,dc=com", "(cn=e*)", SearchScope.SUBTREE, "*" );
int nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "cn", "entryTest" ) );
nbFound++;
}
results.close();
assertEquals( 1, nbFound );
// Ok, now replace the cn
Modification modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "cn", "New cn" );
connection.modify( dn, modification );
// The Substring index on CN should still work
// The old cn should still be present anymore
results = connection.search( "dc=example,dc=com", "(cn=e*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "cn", "entryTest" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Check that we can find the new cn
results = connection.search( "dc=example,dc=com", "(cn=n*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "cn", "New cn" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Now, check the presence index
results = connection.search( "dc=example,dc=com", "(cn=*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "cn", "New cn", "entryTest" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Now, check that the index on displayName is correctly updated
modification = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, "displayName", "testUser" );
connection.modify( dn, modification );
// Check the displayName index
results = connection.search( "dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "displayName", "testUser" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Now, check the presence index
results = connection.search( "dc=example,dc=com", "(displayName=*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertTrue( result.contains( "displayName", "testUser" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Delete the entry
connection.delete( dn );
}