try
{
// Use the netscape API as JNDI cannot be used to do a search without
// first binding.
LDAPUrl url = new LDAPUrl( "localhost", ldapServer.getPort(), "", new String[]{"vendorName"}, 0, "(ObjectClass=*)" );
LDAPSearchResults results = LDAPConnection.search( url );
if ( results.hasMoreElements() )
{
LDAPEntry entry = results.next();
LDAPAttribute vendorName = entry.getAttribute( "vendorName" );
if ( vendorName != null )
{
assertEquals( "Apache Software Foundation", vendorName.getStringValueArray()[0] );
}
else
{
fail();
}
}
else
{
fail();
}
}
catch ( LDAPException e )
{
fail( "Should not have caught exception." );
}
// Check that we cannot read another entry being anonymous
try
{
// Use the netscape API as JNDI cannot be used to do a search without
// first binding.
LDAPUrl url = new LDAPUrl( "localhost", ldapServer.getPort(),
"uid=admin,ou=system", attrIDs, 0, "(ObjectClass=*)" );
LDAPSearchResults results = LDAPConnection.search( url );
fail();
}
catch ( LDAPException e )
{