Skip to content

add user group as well as user OU #218

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion defaults/config.ini.default
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ uri = "ldap://identity" ; URI of remote LDAP server
user = "cn=admin,dc=unityhpc,dc=test" ; Admin bind DN LDAP user
pass = "password" ; Admin bind password
basedn = "dc=unityhpc,dc=test" ; Base search DN
user_ou = "ou=users,dc=unityhpc,dc=test" ; User organizational unit
user_ou = "ou=users,dc=unityhpc,dc=test" ; User organizational unit (may contain more than user group)
user_group = "cn=unityusers,dc=unityhpc,dc=test" ; User group
group_ou = "ou=groups,dc=unityhpc,dc=test" ; Group organizational unit
pigroup_ou = "ou=pi_groups,dc=unityhpc,dc=test" ; PI Group organizational unit
orggroup_ou = "ou=org_groups,dc=unityhpc,dc=test" ; ORG group organizational unit
Expand Down
1 change: 1 addition & 0 deletions resources/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
$CONFIG["ldap"]["pigroup_ou"],
$CONFIG["ldap"]["orggroup_ou"],
$CONFIG["ldap"]["admin_group"],
$CONFIG["ldap"]["user_group"],
$CONFIG["ldap"]["def_user_shell"]
);

Expand Down
13 changes: 10 additions & 3 deletions resources/lib/UnityLDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function __construct(
$pigroup_ou,
$orggroup_ou,
$admin_group,
$user_group_dn,
$def_user_shell
) {
parent::__construct($host, $dn, $pass);
Expand All @@ -69,6 +70,7 @@ public function __construct(
$this->pi_groupOU = $this->getEntry($pigroup_ou);
$this->org_groupOU = $this->getEntry($orggroup_ou);
$this->adminGroup = $this->getEntry($admin_group);
$this->userGroup = $this->getEntry($user_group_dn);

$this->custom_mappings_path = $custom_user_mappings;

Expand Down Expand Up @@ -103,6 +105,11 @@ public function getAdminGroup()
return $this->adminGroup;
}

public function getUserGroup()
{
return $this->userGroup;
}

public function getDefUserShell()
{
return $this->def_user_shell;
Expand Down Expand Up @@ -236,10 +243,10 @@ public function getAllUsers($UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook,
}
}

$users = $this->userOU->getChildren(true);

$users = $this->userGroup->getAttribute("memberuid");
sort($users);
foreach ($users as $user) {
$params = array($user->getAttribute("cn")[0], $this, $UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook);
$params = array($user, $this, $UnitySQL, $UnityMailer, $UnityRedis, $UnityWebhook);
array_push($out, new UnityUser(...$params));
}

Expand Down
4 changes: 4 additions & 0 deletions resources/lib/UnityUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public function init($send_mail = true)
$orgEntry->addUser($this);
}

// add to user group as well as user OU
$this->LDAP->getUserGroup()->appendAttribute("memberuid", $this->getUID());
$this->LDAP->getUserGroup()->write();

// add user to cache
$this->REDIS->appendCacheArray("sorted_users", "", $this->getUID());

Expand Down
Loading
Loading