}
// Look for a local server with the Ldap Port.
InternalSearchOperation op = null;
String attrName = "hostname";
AttributeType hostnameType = DirectoryServer.getAttributeType(attrName);
if (hostnameType == null)
{
hostnameType = DirectoryServer.getDefaultAttributeType(attrName);
}
try
{
op = internalConnection.processSearch("cn=Servers,cn=admin data",
SearchScope.SINGLE_LEVEL, "objectclass=*");
if (op.getResultCode() == ResultCode.SUCCESS)
{
Entry entry = null;
for (Entry currentEntry : op.getSearchEntries())
{
String currentHostname = currentEntry.getAttributeValue(hostnameType,
DirectoryStringSyntax.DECODER);
try
{
String currentIPAddress = java.net.InetAddress.getByName(
currentHostname).getCanonicalHostName();
if (currentIPAddress.equals(hostName))
{
// Check if one of the port match
attrName = "ldapport";
AttributeType portType = DirectoryServer
.getAttributeType(attrName);
if (portType == null)
{
portType = DirectoryServer.getDefaultAttributeType(attrName);
}