From c02ca9a6d3ef14fe745f66acd5f9b2c7e58d5563 Mon Sep 17 00:00:00 2001 From: David Schramm Date: Thu, 7 Nov 2024 16:45:47 +0100 Subject: [PATCH] get username from user dn of member attribute --- functions.inc/auth/modules/Openldap2.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/functions.inc/auth/modules/Openldap2.php b/functions.inc/auth/modules/Openldap2.php index e70b13cc..fdeeaf07 100644 --- a/functions.inc/auth/modules/Openldap2.php +++ b/functions.inc/auth/modules/Openldap2.php @@ -1024,6 +1024,8 @@ private function updateAllGroups() { // Open issues: https://github.com/Adldap2/Adldap2/issues/794 if ($this->config['groupmemberidentifierattr'] == "uid") { $getMembers = $result[$this->config['groupmemberattr']]; + } else if ($this->config['groupmemberidentifierattr'] == "cn") { + $getMembers = $result[$this->config['groupmemberattr']]; } else { $getMembers = $result->getMembers(); } @@ -1034,7 +1036,12 @@ private function updateAllGroups() { if ($member instanceof Group) { $m = $this->getUserByUsername($member->getAccountName()); } else { - $m = $this->getUserByUsername($member); + if ($this->config['groupmemberidentifierattr'] == "cn") { + $stripped_username=explode(",", explode("=", $member)[1])[0]; + $m = $this->getUserByUsername($stripped_username); + } else { + $m = $this->getUserByUsername($member); + } } if(!empty($m)) { $this->out("\t\t\tAdding ".$m['username']." to group");