From 387fbabc59cbb1acb11630764e4633925e413a11 Mon Sep 17 00:00:00 2001 From: Liam Morland <lkmorlan@uwaterloo.ca> Date: Thu, 28 Oct 2021 13:37:41 -0400 Subject: [PATCH] ISTWCMS-4907: Create uw_cfg_common_get_user_ad_groups() --- uw_cfg_common.module | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uw_cfg_common.module b/uw_cfg_common.module index ae7847a9..20ae4ee7 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -632,3 +632,14 @@ function uw_cfg_common_array_split_clean(?string $data): array { $data = array_unique($data); return $data; } + +/** + * Return the Active Directory groups that the current user is part of. + * + * @return null|string[] + * An array of Active Directory group names or NULL if unable to determine. + */ +function uw_cfg_common_get_user_ad_groups(): ?array { + $attributes = \Drupal::service('simplesamlphp_auth.manager')->getAttributes(); + return $attributes['http://schemas.xmlsoap.org/claims/Group'] ?? NULL; +} -- GitLab