diff --git a/config/config.php.example b/config/config.php.example
index a5377f3..c9dcd70 100644
--- a/config/config.php.example
+++ b/config/config.php.example
@@ -431,6 +431,9 @@ $servers->setValue('server','name','My LDAP Server');
/* Set to true if you would like to initially open the first level of each tree. */
// $servers->setValue('appearance','open_tree',false);
+/* Set to true to display authorization ID in place of login dn (PHP 7.2+) */
+// $servers->setValue('appearance','show_authz',false);
+
/* This feature allows phpLDAPadmin to automatically determine the next
available uidNumber for a new entry. */
// $servers->setValue('auto_number','enable',true);
diff --git a/lib/HTMLTree.php b/lib/HTMLTree.php
index 90861cb..2345011 100644
--- a/lib/HTMLTree.php
+++ b/lib/HTMLTree.php
@@ -45,7 +45,8 @@ class HTMLTree extends Tree {
if (! $onlytree) {
$this->draw_menu();
- if ($server->getAuthType() != 'config')
+ if (($server->getAuthType() != 'config') ||
+ $server->getValue('appearance', 'show_authz'))
$this->draw_logged_in_user();
else
printf('
|
',$this->getDepth()+3);
@@ -344,7 +345,7 @@ class HTMLTree extends Tree {
$server = $this->getServer();
- $logged_in_dn = $server->getLogin(null);
+ $logged_in_dn = $server->displayLogin(null);
echo '';
echo ' | ';
printf('%s: ',$this->getDepth()+3-1,_('Logged in as'));
diff --git a/lib/ds_ldap_pla.php b/lib/ds_ldap_pla.php
index 4065109..5c9c15a 100644
--- a/lib/ds_ldap_pla.php
+++ b/lib/ds_ldap_pla.php
@@ -28,6 +28,10 @@ class ldap_pla extends ldap {
'desc'=>'Whether to initially open each tree',
'default'=>false);
+ $this->default->appearance['show_authz'] = array(
+ 'desc'=>'Enable display of authorization ID as login',
+ 'default'=>false);
+
$this->default->login['fallback_dn'] = array(
'desc'=>'If the attribute base login fails, see if a DN was entered',
'default'=>false);
@@ -655,5 +659,23 @@ class ldap_pla extends ldap {
$_SESSION['ACTIVITY'][$this->getIndex()] = $this->inactivityTime();
return true;
}
+
+ /**
+ * Return login, or authorization ID if show_authz enabled
+ */
+ public function displayLogin($method=null) {
+ // check for whoami function, added in 7.2
+ if ($this->getValue('appearance', 'show_authz') && function_exists('ldap_exop_whoami')) {
+ $result = @ldap_exop_whoami($this->connect($method));
+ if ($result) // strip any dn: or u: prefix
+ $result = preg_replace('/^(u|dn):/i', '', $result);
+ else // fall back to login on error
+ $result = $this->getLogin($method);
+ return $result;
+ }
+ else {
+ return $this->getLogin($method);
+ }
+ }
}
?>
|