diff --git a/uw_cfg_common.module b/uw_cfg_common.module index ae7847a9c2dd477acf5c7a725acef22fb205c33c..20ae4ee7acce3a01d1c44ccbdf7dd51dda8ac811 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; +}