"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.REMOVE_ATTRIBUTE, "displayName",
"testEntry" );
connection.modify( dn, modification );
// We should not find anything using the substring filter for the displayName AT
results = connection.search( "dc=example,dc=com", "(displayName=t*)", SearchScope.SUBTREE, "*" );
assertFalse( results.next() );
results.close();
// Check that we cannot find the displayName using the presence index
results = connection.search( "dc=example,dc=com", "(displayName=n*)", SearchScope.SUBTREE, "*" );
assertFalse( results.next() );
results.close();
// Now, Delete one value from the cn index
modification = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, "cn", "test2" );
connection.modify( dn, modification );
// Check the cn index using the remaining value
results = connection.search( "dc=example,dc=com", "(cn=E*)", SearchScope.SUBTREE, "*" );
nbFound = 0;
while ( results.next() )
{
Entry result = results.get();
assertFalse( result.contains( "cn", "test2" ) );
assertTrue( result.contains( "cn", "entryTest" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Check the cn index using the removed value
results = connection.search( "dc=example,dc=com", "(cn=t*)", SearchScope.SUBTREE, "*" );
assertFalse( results.next() );
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();
assertFalse( result.contains( "cn", "test2" ) );
assertTrue( result.contains( "cn", "entryTest" ) );
nbFound++;
}
assertEquals( 1, nbFound );
results.close();
// Delete the entry
connection.delete( dn );
}