Skip to content

Commit 8a428ca

Browse files
authored
add user group as well as user OU (#218)
* add site specific users group * use site specific users group for LDAP->getAllUsers() * add site specific users to docker ldap * distinguish between "user OU" and "user group" * comment * add object classes
1 parent 6d84cd3 commit 8a428ca

File tree

5 files changed

+1328
-4
lines changed

5 files changed

+1328
-4
lines changed

defaults/config.ini.default

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ uri = "ldap://identity" ; URI of remote LDAP server
1818
user = "cn=admin,dc=unityhpc,dc=test" ; Admin bind DN LDAP user
1919
pass = "password" ; Admin bind password
2020
basedn = "dc=unityhpc,dc=test" ; Base search DN
21-
user_ou = "ou=users,dc=unityhpc,dc=test" ; User organizational unit
21+
user_ou = "ou=users,dc=unityhpc,dc=test" ; User organizational unit (may contain more than user group)
22+
user_group = "cn=unityusers,dc=unityhpc,dc=test" ; User group
2223
group_ou = "ou=groups,dc=unityhpc,dc=test" ; Group organizational unit
2324
pigroup_ou = "ou=pi_groups,dc=unityhpc,dc=test" ; PI Group organizational unit
2425
orggroup_ou = "ou=org_groups,dc=unityhpc,dc=test" ; ORG group organizational unit

resources/init.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
$CONFIG["ldap"]["pigroup_ou"],
4646
$CONFIG["ldap"]["orggroup_ou"],
4747
$CONFIG["ldap"]["admin_group"],
48+
$CONFIG["ldap"]["user_group"],
4849
$CONFIG["ldap"]["def_user_shell"]
4950
);
5051

resources/lib/UnityLDAP.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function __construct(
5353
$pigroup_ou,
5454
$orggroup_ou,
5555
$admin_group,
56+
$user_group_dn,
5657
$def_user_shell
5758
) {
5859
parent::__construct($host, $dn, $pass);
@@ -69,6 +70,7 @@ public function __construct(
6970
$this->pi_groupOU = $this->getEntry($pigroup_ou);
7071
$this->org_groupOU = $this->getEntry($orggroup_ou);
7172
$this->adminGroup = $this->getEntry($admin_group);
73+
$this->userGroup = $this->getEntry($user_group_dn);
7274

7375
$this->custom_mappings_path = $custom_user_mappings;
7476

@@ -103,6 +105,11 @@ public function getAdminGroup()
103105
return $this->adminGroup;
104106
}
105107

108+
public function getUserGroup()
109+
{
110+
return $this->userGroup;
111+
}
112+
106113
public function getDefUserShell()
107114
{
108115
return $this->def_user_shell;
@@ -236,10 +243,10 @@ public function getAllUsers($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook,
236243
}
237244
}
238245

239-
$users = $this->userOU->getChildren(true);
240-
246+
$users = $this->userGroup->getAttribute("memberuid");
247+
sort($users);
241248
foreach ($users as $user) {
242-
$params = array($user->getAttribute("cn")[0], $this, $UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook);
249+
$params = array($user, $this, $UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook);
243250
array_push($out, new UnityUser(...$params));
244251
}
245252

resources/lib/UnityUser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function init($send_mail = true)
106106
$orgEntry->addUser($this);
107107
}
108108

109+
// add to user group as well as user OU
110+
$this->LDAP->getUserGroup()->appendAttribute("memberuid", $this->getUID());
111+
$this->LDAP->getUserGroup()->write();
112+
109113
// add user to cache
110114
$this->REDIS->appendCacheArray("sorted_users", "", $this->getUID());
111115

0 commit comments

Comments
 (0)