*/
class LdapService
{
- protected $ldap;
- protected $groupSyncService;
+ protected Ldap $ldap;
+ protected GroupSyncService $groupSyncService;
+ protected UserAvatars $userAvatars;
+
+ /**
+ * @var resource
+ */
protected $ldapConnection;
- protected $userAvatars;
- protected $config;
- protected $enabled;
+
+ protected array $config;
+ protected bool $enabled;
/**
* LdapService constructor.
* Bind the system user to the LDAP connection using the given credentials
* otherwise anonymous access is attempted.
*
- * @param $connection
+ * @param resource $connection
*
* @throws LdapException
*/
* Get the groups a user is a part of on ldap.
*
* @throws LdapException
+ * @throws JsonDebugException
*/
public function getUserGroups(string $userName): array
{
}
$userGroups = $this->groupFilter($user);
- return $this->getGroupsRecursive($userGroups, []);
+ $allGroups = $this->getGroupsRecursive($userGroups, []);
+
+ if ($this->config['dump_user_groups']) {
+ throw new JsonDebugException([
+ 'details_from_ldap' => $user,
+ 'parsed_direct_user_groups' => $userGroups,
+ 'parsed_recursive_user_groups' => $allGroups,
+ ]);
+ }
+
+ return $allGroups;
}
/**
* Sync the LDAP groups to the user roles for the current user.
*
* @throws LdapException
+ * @throws JsonDebugException
*/
public function syncGroups(User $user, string $username)
{