Cleaned code. Fixed undefined userSID warning when LDAP bind failed. Added attribute table error message when LDAP bind failed.

This commit is contained in:
William Mead 2024-03-13 14:34:46 +01:00
parent 996f915192
commit 2baab69aa0

View file

@ -33,7 +33,7 @@ $langs->loadLangs(array('users', 'admin', 'companies', 'ldap'));
$id = GETPOSTINT('id');
$action = GETPOST('action', 'aZ09');
$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'userldap'; // To manage different context of search
$contextpage = GETPOST('contextpage', 'aZ') ?: 'userldap'; // To manage different context of search
// Security check
$socid = 0;
@ -125,9 +125,7 @@ print '</tr>';
if (getDolGlobalString('LDAP_SERVER_TYPE') == "activedirectory") {
$ldap = new Ldap();
$result = $ldap->connectBind();
if ($result > 0) {
$userSID = $ldap->getObjectSid($object->login);
}
($result > 0) ? ($userSID = $ldap->getObjectSid($object->login)) : $userSID = '';
print '<tr><td class="valigntop">'.$langs->trans("SID").'</td>';
print '<td>'.$userSID.'</td>';
print "</tr>\n";
@ -204,6 +202,7 @@ if ($result > 0) {
$ldap->unbind();
} else {
print '<tr class="oddeven"><td colspan="2"><span class="error">'.$langs->trans("ErrorFailedToReadLDAP").'</span></td></tr>';
setEventMessages($ldap->error, $ldap->errors, 'errors');
}