From 2baab69aa01dcf869aadad7244221fa08322b7fd Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 13 Mar 2024 14:34:46 +0100 Subject: [PATCH 1/3] Cleaned code. Fixed undefined userSID warning when LDAP bind failed. Added attribute table error message when LDAP bind failed. --- htdocs/user/ldap.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index ab95f1ad25e..47b9017b008 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -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 ''; 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 ''.$langs->trans("SID").''; print ''.$userSID.''; print "\n"; @@ -204,6 +202,7 @@ if ($result > 0) { $ldap->unbind(); } else { + print ''.$langs->trans("ErrorFailedToReadLDAP").''; setEventMessages($ldap->error, $ldap->errors, 'errors'); } From 06a593a2c3aee24940e8f733ee15f17646a8a920 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 13 Mar 2024 14:36:04 +0100 Subject: [PATCH 2/3] Added contributor details --- htdocs/user/ldap.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 47b9017b008..f2e9a3708d2 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -1,6 +1,7 @@ - * Copyright (C) 2006-2021 Regis Houssin +/* Copyright (C) 2006-2012 Laurent Destailleur + * Copyright (C) 2006-2021 Regis Houssin + * Copyright (C) 2024 William Mead * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by From 439654a634209b505c367fb2334ce089e195c129 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Mar 2024 18:24:35 +0100 Subject: [PATCH 3/3] Fix ternary of ternary too difficult to read --- htdocs/user/ldap.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index f2e9a3708d2..328e14910ae 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -126,7 +126,10 @@ print ''; if (getDolGlobalString('LDAP_SERVER_TYPE') == "activedirectory") { $ldap = new Ldap(); $result = $ldap->connectBind(); - ($result > 0) ? ($userSID = $ldap->getObjectSid($object->login)) : $userSID = ''; + $userSID = ''; + if ($result > 0) { + $userSID = $ldap->getObjectSid($object->login); + } print ''.$langs->trans("SID").''; print ''.$userSID.''; print "\n";