// Check that we can read the rootDSE
try
{
// Use the netscape API as JNDI cannot be used to do a search without
// first binding.
LDAPUrl url = new LDAPUrl( "localhost", getLdapServer().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", getLdapServer().getPort(), "uid=admin,ou=system", attrIDs, 0,
"(ObjectClass=*)" );
LDAPConnection.search( url );
fail();
}