Wizard: make AD discovery working again

refs #2153
This commit is contained in:
Alexander A. Klimov 2017-06-20 14:46:44 +02:00
parent 6668556e50
commit 9237c3e27d

View File

@ -373,30 +373,34 @@ class LdapCapabilities
(string) $connection->select()->from('*', $adFields)->where('nCName', $defaultNamingContext), (string) $connection->select()->from('*', $adFields)->where('nCName', $defaultNamingContext),
$adFields $adFields
); );
if (! $result) { if ($result) {
throw new LdapException( $entry = ldap_first_entry($ds, $result);
'Configuration options query failed (%s:%d): %s. Check if hostname and port of the' if ($entry === false) {
. ' ldap resource are correct and if anonymous access is permitted.', throw new LdapException(
$connection->getHostname(), 'Configuration options not available (%s:%d). Discovery of "%s" probably not permitted.',
$connection->getPort(), $connection->getHostname(),
ldap_error($ds) $connection->getPort(),
); $partitions
} );
}
$entry = ldap_first_entry($ds, $result); $this->setAttributes((object) array_merge(
if ($entry === false) { (array) $this->attributes,
throw new LdapException( (array) $connection->cleanupAttributes(ldap_get_attributes($ds, $entry), $adFields)
'Configuration options not available (%s:%d). Discovery of "' ));
. $partitions . '" probably not permitted.', } else {
$connection->getHostname(), if (ldap_errno($ds) !== 1) {
$connection->getPort() // One stands for "operations error" which occurs if not bound non-anonymously.
);
}
$this->setAttributes((object) array_merge( throw new LdapException(
(array) $this->attributes, 'Configuration options query failed (%s:%d): %s. Check if hostname and port of the'
(array) $connection->cleanupAttributes(ldap_get_attributes($ds, $entry), $adFields) . ' ldap resource are correct and if anonymous access is permitted.',
)); $connection->getHostname(),
$connection->getPort(),
ldap_error($ds)
);
}
}
} }
} }
} }