diff options
author | Ermal Luçi <eri@pfsense.org> | 2010-03-09 17:54:00 +0000 |
---|---|---|
committer | Ermal Luçi <eri@pfsense.org> | 2010-03-09 17:54:00 +0000 |
commit | fb0f22c0ec9b86c79b9623d6b710a5f47741b3b6 (patch) | |
tree | aace734ee851d5927f5a5337c2a2ad96326da5b5 /etc | |
parent | 61bda182d488e9a713d5963d93e6f646bf851f87 (diff) | |
download | pfsense-fb0f22c0ec9b86c79b9623d6b710a5f47741b3b6.zip pfsense-fb0f22c0ec9b86c79b9623d6b710a5f47741b3b6.tar.gz |
Add a function to get user groups based on authentication server. Use this function to show the groups the user i member of on Diag Authentication.
Diffstat (limited to 'etc')
-rw-r--r-- | etc/inc/auth.inc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/etc/inc/auth.inc b/etc/inc/auth.inc index 302e1fe..6a0d941 100644 --- a/etc/inc/auth.inc +++ b/etc/inc/auth.inc @@ -1018,6 +1018,33 @@ function auth_get_authserver_list() { return $list; } +function getUserGroups($username, $authcfg) { + global $config; + + $allowed_groups = array(); + + switch($authcfg['type']) { + case 'ldap': + $allowed_groups = @ldap_get_groups($username, $authcfg); + break; + case 'radius': + break; + default: + $user = getUserEntry($username); + $allowed_groups = @local_user_get_groups($user, true); + break; + } + + $member_groups = array(); + if (is_array($config['system']['group'])) { + foreach ($config['system']['group'] as $group) + if (in_array($group['name'], $allowed_groups)) + $member_groups[] = $group['name']; + } + + return $member_groups; +} + function authenticate_user($username, $password, $authcfg = NULL) { if (!$authcfg) { |