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
1 changed files with 26 additions and 22 deletions

View File

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