From 932b89e494ef2f1026f462cc104aec9ded065e26 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Sat, 5 Jul 2025 12:49:37 -0400 Subject: [PATCH 1/4] store entry as property --- resources/lib/UnityGroup.php | 19 ++++++------- resources/lib/UnityUser.php | 50 ++++++++++++++------------------- test/functional/NewUserTest.php | 6 ++-- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/resources/lib/UnityGroup.php b/resources/lib/UnityGroup.php index 9fac0191..9bebb004 100644 --- a/resources/lib/UnityGroup.php +++ b/resources/lib/UnityGroup.php @@ -12,6 +12,7 @@ class UnityGroup public const PI_PREFIX = "pi_"; private $pi_uid; + private $entry; // Services private $LDAP; @@ -30,6 +31,7 @@ class UnityGroup public function __construct($pi_uid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) { $this->pi_uid = $pi_uid; + $this->entry = $LDAP->getPIGroupEntry($pi_uid); $this->LDAP = $LDAP; $this->SQL = $SQL; @@ -69,7 +71,7 @@ public function getPIUID() */ public function exists() { - return $this->getLDAPPiGroup()->exists(); + return $this->entry->exists(); } // @@ -265,7 +267,7 @@ public function cancelGroupJoinRequest($user, $send_mail = true) // $users = $this->getGroupMembers(); // // now we delete the ldap entry - // $ldapPiGroupEntry = $this->getLDAPPiGroup(); + // $ldapPiGroupEntry = $this->entry; // if ($ldapPiGroupEntry->exists()) { // $ldapPiGroupEntry->delete(); // $this->REDIS->removeCacheArray("sorted_groups", "", $this->getPIUID()); @@ -501,7 +503,7 @@ public function getGroupMemberUIDs($ignorecache = false) } $updatecache = false; if (!isset($members)) { - $pi_group = $this->getLDAPPiGroup(); + $pi_group = $this->entry; $members = $pi_group->getAttribute("memberuid"); $updatecache = true; } @@ -536,7 +538,7 @@ private function init() $owner = $this->getOwner(); // (1) Create LDAP PI group - $ldapPiGroupEntry = $this->getLDAPPiGroup(); + $ldapPiGroupEntry = $this->entry; if (!$ldapPiGroupEntry->exists()) { $nextGID = $this->LDAP->getNextPiGIDNumber($this->SQL); @@ -555,7 +557,7 @@ private function init() private function addUserToGroup($new_user) { // Add to LDAP Group - $pi_group = $this->getLDAPPiGroup(); + $pi_group = $this->entry; $pi_group->appendAttribute("memberuid", $new_user->getUID()); $pi_group->write(); $this->REDIS->appendCacheArray($this->getPIUID(), "members", $new_user->getUID()); @@ -565,7 +567,7 @@ private function addUserToGroup($new_user) private function removeUserFromGroup($old_user) { // Remove from LDAP Group - $pi_group = $this->getLDAPPiGroup(); + $pi_group = $this->entry; $pi_group->removeAttributeEntryByValue("memberuid", $old_user->getUID()); $pi_group->write(); $this->REDIS->removeCacheArray($this->getPIUID(), "members", $old_user->getUID()); @@ -598,11 +600,6 @@ public function getOwner() ); } - public function getLDAPPiGroup() - { - return $this->LDAP->getPIGroupEntry($this->pi_uid); - } - public static function getPIUIDfromUID($uid) { return self::PI_PREFIX . $uid; diff --git a/resources/lib/UnityUser.php b/resources/lib/UnityUser.php index 983e2a5f..cfadf66c 100644 --- a/resources/lib/UnityUser.php +++ b/resources/lib/UnityUser.php @@ -10,6 +10,7 @@ class UnityUser private const HOME_DIR = "/home/"; private $uid; + private $entry; // service stack private $LDAP; @@ -21,6 +22,7 @@ class UnityUser public function __construct($uid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) { $this->uid = $uid; + $this->entry = $LDAP->getUserEntry($uid); $this->LDAP = $LDAP; $this->SQL = $SQL; @@ -70,7 +72,7 @@ public function init($firstname, $lastname, $email, $org, $send_mail = true) // // Create LDAP user // - $ldapUserEntry = $this->getLDAPUser(); + $ldapUserEntry = $this->entry; if (!$ldapUserEntry->exists()) { $ldapUserEntry->setAttribute("objectclass", UnityLDAP::POSIX_ACCOUNT_CLASS); @@ -141,16 +143,6 @@ public function init($firstname, $lastname, $email, $org, $send_mail = true) } } - /** - * Returns the ldap account entry corresponding to the user - * - * @return ldapEntry posix account - */ - public function getLDAPUser() - { - return $this->LDAP->getUserEntry($this->uid); - } - /** * Returns the ldap group entry corresponding to the user * @@ -163,7 +155,7 @@ public function getLDAPGroup() public function exists() { - return $this->getLDAPUser()->exists() && $this->getLDAPGroup()->exists(); + return $this->entry->exists() && $this->getLDAPGroup()->exists(); } // @@ -182,7 +174,7 @@ public function getUID() public function setOrg($org) { - $ldap_user = $this->getLDAPUser(); + $ldap_user = $this->entry; $ldap_user->setAttribute("o", $org); $ldap_user->write(); $this->REDIS->setCache($this->uid, "org", $org); @@ -199,13 +191,13 @@ public function getOrg($ignorecache = false) } if ($this->exists()) { - $org = $this->getLDAPUser()->getAttribute("o")[0]; + $org = $this->entry->getAttribute("o")[0]; if (!$ignorecache) { $this->REDIS->setCache($this->getUID(), "org", $org); } - return $this->getLDAPUser()->getAttribute("o")[0]; + return $this->entry->getAttribute("o")[0]; } return null; @@ -218,7 +210,7 @@ public function getOrg($ignorecache = false) */ public function setFirstname($firstname, $operator = null) { - $ldap_user = $this->getLDAPUser(); + $ldap_user = $this->entry; $ldap_user->setAttribute("givenname", $firstname); $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); @@ -249,7 +241,7 @@ public function getFirstname($ignorecache = false) } if ($this->exists()) { - $firstname = $this->getLDAPUser()->getAttribute("givenname")[0]; + $firstname = $this->entry->getAttribute("givenname")[0]; if (!$ignorecache) { $this->REDIS->setCache($this->getUID(), "firstname", $firstname); @@ -268,7 +260,7 @@ public function getFirstname($ignorecache = false) */ public function setLastname($lastname, $operator = null) { - $ldap_user = $this->getLDAPUser(); + $ldap_user = $this->entry; $ldap_user->setAttribute("sn", $lastname); $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); @@ -279,7 +271,7 @@ public function setLastname($lastname, $operator = null) $this->getUID() ); - $this->getLDAPUser()->write(); + $this->entry->write(); $this->REDIS->setCache($this->uid, "lastname", $lastname); } @@ -299,7 +291,7 @@ public function getLastname($ignorecache = false) } if ($this->exists()) { - $lastname = $this->getLDAPUser()->getAttribute("sn")[0]; + $lastname = $this->entry->getAttribute("sn")[0]; if (!$ignorecache) { $this->REDIS->setCache($this->getUID(), "lastname", $lastname); @@ -324,7 +316,7 @@ public function getFullname() */ public function setMail($email, $operator = null) { - $ldap_user = $this->getLDAPUser(); + $ldap_user = $this->entry; $ldap_user->setAttribute("mail", $email); $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); @@ -335,7 +327,7 @@ public function setMail($email, $operator = null) $this->getUID() ); - $this->getLDAPUser()->write(); + $this->entry->write(); $this->REDIS->setCache($this->uid, "mail", $email); } @@ -355,7 +347,7 @@ public function getMail($ignorecache = false) } if ($this->exists()) { - $mail = $this->getLDAPUser()->getAttribute("mail")[0]; + $mail = $this->entry->getAttribute("mail")[0]; if (!$ignorecache) { $this->REDIS->setCache($this->getUID(), "mail", $mail); @@ -374,7 +366,7 @@ public function getMail($ignorecache = false) */ public function setSSHKeys($keys, $operator = null, $send_mail = true) { - $ldapUser = $this->getLDAPUser(); + $ldapUser = $this->entry; $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); $keys_filt = array_values(array_unique($keys)); if ($ldapUser->exists()) { @@ -419,7 +411,7 @@ public function getSSHKeys($ignorecache = false) } if ($this->exists()) { - $ldapUser = $this->getLDAPUser(); + $ldapUser = $this->entry; $result = $ldapUser->getAttribute("sshpublickey"); if (is_null($result)) { $keys = array(); @@ -454,7 +446,7 @@ public function setLoginShell($shell, $operator = null, $send_mail = true) if (empty($shell)) { throw new Exception("login shell must not be empty!"); } - $ldapUser = $this->getLDAPUser(); + $ldapUser = $this->entry; if ($ldapUser->exists()) { $ldapUser->setAttribute("loginshell", $shell); $ldapUser->write(); @@ -496,7 +488,7 @@ public function getLoginShell($ignorecache = false) } if ($this->exists()) { - $ldapUser = $this->getLDAPUser(); + $ldapUser = $this->entry; $loginshell = $ldapUser->getAttribute("loginshell")[0]; @@ -512,7 +504,7 @@ public function getLoginShell($ignorecache = false) public function setHomeDir($home, $operator = null) { - $ldapUser = $this->getLDAPUser(); + $ldapUser = $this->entry; if ($ldapUser->exists()) { $ldapUser->setAttribute("homedirectory", $home); $ldapUser->write(); @@ -545,7 +537,7 @@ public function getHomeDir($ignorecache = false) } if ($this->exists()) { - $ldapUser = $this->getLDAPUser(); + $ldapUser = $this->entry; $homedir = $ldapUser->getAttribute("homedirectory"); diff --git a/test/functional/NewUserTest.php b/test/functional/NewUserTest.php index b0f0fb23..4f897d68 100644 --- a/test/functional/NewUserTest.php +++ b/test/functional/NewUserTest.php @@ -65,7 +65,7 @@ private function ensureUserDoesNotExist() $org->removeUser($USER); assert(!$org->inOrg($USER)); } - $USER->getLDAPUser()->delete(); + $LDAP->getUserEntry($USER->getUID())->delete(); assert(!$USER->exists()); } $all_users_group = $LDAP->getUserGroup(); @@ -102,9 +102,9 @@ private function ensureUserNotInPIGroup(UnityGroup $pi_group) private function ensurePIGroupDoesNotExist() { - global $USER; + global $USER, $LDAP; if ($USER->getPIGroup()->exists()) { - $USER->getPIGroup()->getLDAPPIGroup()->delete(); + $LDAP->getPIGroupEntry($USER->getPIGroup()->getPIUID())->delete(); assert(!$USER->getPIGroup()->exists()); } } From f46cc39e76aabc8f3c6f4a78c75c3a2555ef77b0 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Sat, 5 Jul 2025 12:52:02 -0400 Subject: [PATCH 2/4] don't store extra variable for $this->entry --- resources/lib/UnityGroup.php | 31 ++++++--------- resources/lib/UnityUser.php | 76 +++++++++++++++--------------------- 2 files changed, 43 insertions(+), 64 deletions(-) diff --git a/resources/lib/UnityGroup.php b/resources/lib/UnityGroup.php index 9bebb004..c0b79d9b 100644 --- a/resources/lib/UnityGroup.php +++ b/resources/lib/UnityGroup.php @@ -267,9 +267,8 @@ public function cancelGroupJoinRequest($user, $send_mail = true) // $users = $this->getGroupMembers(); // // now we delete the ldap entry - // $ldapPiGroupEntry = $this->entry; - // if ($ldapPiGroupEntry->exists()) { - // $ldapPiGroupEntry->delete(); + // if ($this->entry->exists()) { + // $this->entry->delete(); // $this->REDIS->removeCacheArray("sorted_groups", "", $this->getPIUID()); // foreach ($users as $user) { // $this->REDIS->removeCacheArray($user->getUID(), "groups", $this->getPIUID()); @@ -503,8 +502,7 @@ public function getGroupMemberUIDs($ignorecache = false) } $updatecache = false; if (!isset($members)) { - $pi_group = $this->entry; - $members = $pi_group->getAttribute("memberuid"); + $members = $this->entry->getAttribute("memberuid"); $updatecache = true; } if (!$ignorecache && $updatecache) { @@ -537,16 +535,13 @@ private function init() // make this user a PI $owner = $this->getOwner(); - // (1) Create LDAP PI group - $ldapPiGroupEntry = $this->entry; - - if (!$ldapPiGroupEntry->exists()) { + if (!$this->entry->exists()) { $nextGID = $this->LDAP->getNextPiGIDNumber($this->SQL); - $ldapPiGroupEntry->setAttribute("objectclass", UnityLDAP::POSIX_GROUP_CLASS); - $ldapPiGroupEntry->setAttribute("gidnumber", strval($nextGID)); - $ldapPiGroupEntry->setAttribute("memberuid", array($owner->getUID())); - $ldapPiGroupEntry->write(); + $this->entry->setAttribute("objectclass", UnityLDAP::POSIX_GROUP_CLASS); + $this->entry->setAttribute("gidnumber", strval($nextGID)); + $this->entry->setAttribute("memberuid", array($owner->getUID())); + $this->entry->write(); } $this->REDIS->appendCacheArray("sorted_groups", "", $this->getPIUID()); @@ -557,9 +552,8 @@ private function init() private function addUserToGroup($new_user) { // Add to LDAP Group - $pi_group = $this->entry; - $pi_group->appendAttribute("memberuid", $new_user->getUID()); - $pi_group->write(); + $this->entry->appendAttribute("memberuid", $new_user->getUID()); + $this->entry->write(); $this->REDIS->appendCacheArray($this->getPIUID(), "members", $new_user->getUID()); $this->REDIS->appendCacheArray($new_user->getUID(), "groups", $this->getPIUID()); } @@ -567,9 +561,8 @@ private function addUserToGroup($new_user) private function removeUserFromGroup($old_user) { // Remove from LDAP Group - $pi_group = $this->entry; - $pi_group->removeAttributeEntryByValue("memberuid", $old_user->getUID()); - $pi_group->write(); + $this->entry->removeAttributeEntryByValue("memberuid", $old_user->getUID()); + $this->entry->write(); $this->REDIS->removeCacheArray($this->getPIUID(), "members", $old_user->getUID()); $this->REDIS->removeCacheArray($old_user->getUID(), "groups", $this->getPIUID()); } diff --git a/resources/lib/UnityUser.php b/resources/lib/UnityUser.php index cfadf66c..d967fc71 100644 --- a/resources/lib/UnityUser.php +++ b/resources/lib/UnityUser.php @@ -72,24 +72,22 @@ public function init($firstname, $lastname, $email, $org, $send_mail = true) // // Create LDAP user // - $ldapUserEntry = $this->entry; - - if (!$ldapUserEntry->exists()) { - $ldapUserEntry->setAttribute("objectclass", UnityLDAP::POSIX_ACCOUNT_CLASS); - $ldapUserEntry->setAttribute("uid", $this->uid); - $ldapUserEntry->setAttribute("givenname", $firstname); - $ldapUserEntry->setAttribute("sn", $lastname); - $ldapUserEntry->setAttribute( + if (!$this->entry->exists()) { + $this->entry->setAttribute("objectclass", UnityLDAP::POSIX_ACCOUNT_CLASS); + $this->entry->setAttribute("uid", $this->uid); + $this->entry->setAttribute("givenname", $firstname); + $this->entry->setAttribute("sn", $lastname); + $this->entry->setAttribute( "gecos", \transliterator_transliterate("Latin-ASCII", "$firstname $lastname") ); - $ldapUserEntry->setAttribute("mail", $email); - $ldapUserEntry->setAttribute("o", $org); - $ldapUserEntry->setAttribute("homedirectory", self::HOME_DIR . $this->uid); - $ldapUserEntry->setAttribute("loginshell", $this->LDAP->getDefUserShell()); - $ldapUserEntry->setAttribute("uidnumber", strval($id)); - $ldapUserEntry->setAttribute("gidnumber", strval($id)); - $ldapUserEntry->write(); + $this->entry->setAttribute("mail", $email); + $this->entry->setAttribute("o", $org); + $this->entry->setAttribute("homedirectory", self::HOME_DIR . $this->uid); + $this->entry->setAttribute("loginshell", $this->LDAP->getDefUserShell()); + $this->entry->setAttribute("uidnumber", strval($id)); + $this->entry->setAttribute("gidnumber", strval($id)); + $this->entry->write(); } // update cache @@ -174,9 +172,8 @@ public function getUID() public function setOrg($org) { - $ldap_user = $this->entry; - $ldap_user->setAttribute("o", $org); - $ldap_user->write(); + $this->entry->setAttribute("o", $org); + $this->entry->write(); $this->REDIS->setCache($this->uid, "org", $org); } @@ -210,8 +207,7 @@ public function getOrg($ignorecache = false) */ public function setFirstname($firstname, $operator = null) { - $ldap_user = $this->entry; - $ldap_user->setAttribute("givenname", $firstname); + $this->entry->setAttribute("givenname", $firstname); $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); $this->SQL->addLog( @@ -221,7 +217,7 @@ public function setFirstname($firstname, $operator = null) $this->getUID() ); - $ldap_user->write(); + $this->entry->write(); $this->REDIS->setCache($this->uid, "firstname", $firstname); } @@ -260,8 +256,7 @@ public function getFirstname($ignorecache = false) */ public function setLastname($lastname, $operator = null) { - $ldap_user = $this->entry; - $ldap_user->setAttribute("sn", $lastname); + $this->entry->setAttribute("sn", $lastname); $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); $this->SQL->addLog( @@ -316,8 +311,7 @@ public function getFullname() */ public function setMail($email, $operator = null) { - $ldap_user = $this->entry; - $ldap_user->setAttribute("mail", $email); + $this->entry->setAttribute("mail", $email); $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); $this->SQL->addLog( @@ -366,12 +360,11 @@ public function getMail($ignorecache = false) */ public function setSSHKeys($keys, $operator = null, $send_mail = true) { - $ldapUser = $this->entry; $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); $keys_filt = array_values(array_unique($keys)); - if ($ldapUser->exists()) { - $ldapUser->setAttribute("sshpublickey", $keys_filt); - $ldapUser->write(); + if ($this->entry->exists()) { + $this->entry->setAttribute("sshpublickey", $keys_filt); + $this->entry->write(); } $this->REDIS->setCache($this->uid, "sshkeys", $keys_filt); @@ -411,8 +404,7 @@ public function getSSHKeys($ignorecache = false) } if ($this->exists()) { - $ldapUser = $this->entry; - $result = $ldapUser->getAttribute("sshpublickey"); + $result = $this->entry->getAttribute("sshpublickey"); if (is_null($result)) { $keys = array(); } else { @@ -446,10 +438,9 @@ public function setLoginShell($shell, $operator = null, $send_mail = true) if (empty($shell)) { throw new Exception("login shell must not be empty!"); } - $ldapUser = $this->entry; - if ($ldapUser->exists()) { - $ldapUser->setAttribute("loginshell", $shell); - $ldapUser->write(); + if ($this->entry->exists()) { + $this->entry->setAttribute("loginshell", $shell); + $this->entry->write(); } $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); @@ -488,9 +479,7 @@ public function getLoginShell($ignorecache = false) } if ($this->exists()) { - $ldapUser = $this->entry; - - $loginshell = $ldapUser->getAttribute("loginshell")[0]; + $loginshell = $this->entry->getAttribute("loginshell")[0]; if (!$ignorecache) { $this->REDIS->setCache($this->getUID(), "loginshell", $loginshell); @@ -504,10 +493,9 @@ public function getLoginShell($ignorecache = false) public function setHomeDir($home, $operator = null) { - $ldapUser = $this->entry; - if ($ldapUser->exists()) { - $ldapUser->setAttribute("homedirectory", $home); - $ldapUser->write(); + if ($this->entry->exists()) { + $this->entry->setAttribute("homedirectory", $home); + $this->entry->write(); $operator = is_null($operator) ? $this->getUID() : $operator->getUID(); $this->SQL->addLog( @@ -537,9 +525,7 @@ public function getHomeDir($ignorecache = false) } if ($this->exists()) { - $ldapUser = $this->entry; - - $homedir = $ldapUser->getAttribute("homedirectory"); + $homedir = $this->entry->getAttribute("homedirectory"); if (!$ignorecache) { $this->REDIS->setCache($this->getUID(), "homedir", $homedir); From a9a9908c5c7d379e367e432d231917edb5b4f707 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Sun, 6 Jul 2025 20:59:35 -0400 Subject: [PATCH 3/4] UnityOrg as well --- resources/lib/UnityOrg.php | 34 +++++++++++++-------------------- test/functional/NewUserTest.php | 4 ++-- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/resources/lib/UnityOrg.php b/resources/lib/UnityOrg.php index c965d628..d110c7a4 100644 --- a/resources/lib/UnityOrg.php +++ b/resources/lib/UnityOrg.php @@ -7,6 +7,7 @@ class UnityOrg { private $orgid; + private $entry; private $MAILER; private $SQL; @@ -17,6 +18,7 @@ class UnityOrg public function __construct($orgid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) { $this->orgid = $orgid; + $this->entry = $LDAP->getOrgGroupEntry($this->orgid); $this->LDAP = $LDAP; $this->SQL = $SQL; @@ -27,14 +29,12 @@ public function __construct($orgid, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK) public function init() { - $org_group = $this->getLDAPOrgGroup(); - - if (!$org_group->exists()) { + if (!$this->entry->exists()) { $nextGID = $this->LDAP->getNextOrgGIDNumber($this->SQL); - $org_group->setAttribute("objectclass", UnityLDAP::POSIX_GROUP_CLASS); - $org_group->setAttribute("gidnumber", strval($nextGID)); - $org_group->write(); + $this->entry->setAttribute("objectclass", UnityLDAP::POSIX_GROUP_CLASS); + $this->entry->setAttribute("gidnumber", strval($nextGID)); + $this->entry->write(); } $this->REDIS->appendCacheArray("sorted_orgs", "", $this->getOrgID()); @@ -42,12 +42,7 @@ public function init() public function exists() { - return $this->getLDAPOrgGroup()->exists(); - } - - public function getLDAPOrgGroup() - { - return $this->LDAP->getOrgGroupEntry($this->orgid); + return $this->entry->exists(); } public function getOrgID() @@ -89,8 +84,7 @@ public function getOrgMemberUIDs($ignorecache = false) } $updatecache = false; if (!isset($members)) { - $org_group = $this->getLDAPOrgGroup(); - $members = $org_group->getAttribute("memberuid"); + $members = $this->entry->getAttribute("memberuid"); $updatecache = true; } if (!$ignorecache && $updatecache) { @@ -102,17 +96,15 @@ public function getOrgMemberUIDs($ignorecache = false) public function addUser($user) { - $org_group = $this->getLDAPOrgGroup(); - $org_group->appendAttribute("memberuid", $user->getUID()); - $org_group->write(); - $this->REDIS->appendCacheArray($this->getOrgID(), "members", $user->getUID()); + $this->entry->appendAttribute("memberuid", $user->getUID()); + $this->entry->write(); + $this->REDIS->appendCacheArray($this->getOrgID(), "members", $user->uid); } public function removeUser($user) { - $org_group = $this->getLDAPOrgGroup(); - $org_group->removeAttributeEntryByValue("memberuid", $user->getUID()); - $org_group->write(); + $this->entry->removeAttributeEntryByValue("memberuid", $user->getUID()); + $this->entry->write(); $this->REDIS->removeCacheArray($this->getOrgID(), "members", $user->getUID()); } } diff --git a/test/functional/NewUserTest.php b/test/functional/NewUserTest.php index 4f897d68..02836f26 100644 --- a/test/functional/NewUserTest.php +++ b/test/functional/NewUserTest.php @@ -84,9 +84,9 @@ private function ensureUserDoesNotExist() private function ensureOrgGroupDoesNotExist() { global $USER, $SSO, $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK; - $org_group = new UnityOrg($SSO["org"], $LDAP, $SQL, $MAILER, $REDIS, $WEBHOOK); + $org_group = $LDAP->getOrgGroupEntry($SSO["org"]); if ($org_group->exists()) { - $org_group->getLDAPOrgGroup()->delete(); + $org_group->delete(); assert(!$org_group->exists()); } } From 5d5ca771448e5dd08288d1abd65f51bbe415f577 Mon Sep 17 00:00:00 2001 From: Simon Leary Date: Sun, 6 Jul 2025 21:06:00 -0400 Subject: [PATCH 4/4] use old getuid --- resources/lib/UnityOrg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lib/UnityOrg.php b/resources/lib/UnityOrg.php index d110c7a4..8920830d 100644 --- a/resources/lib/UnityOrg.php +++ b/resources/lib/UnityOrg.php @@ -98,7 +98,7 @@ public function addUser($user) { $this->entry->appendAttribute("memberuid", $user->getUID()); $this->entry->write(); - $this->REDIS->appendCacheArray($this->getOrgID(), "members", $user->uid); + $this->REDIS->appendCacheArray($this->getOrgID(), "members", $user->getUID()); } public function removeUser($user)