function role_assign in Shibboleth Authentication 5.3
Role assign
1 call to role_assign()
- shib_auth_menu in ./
shib_auth.module - Generate the menu element to access the Shibboleth authentication module's administration page @returns HTML text of the administer menu element
File
- ./
shib_auth.module, line 82 - Provides user authentication with Shibboleth (both v1.3 and v2.0) as well as some authorisation features (automatic role assignment base on Shibboleth attributes).
Code
function role_assign() {
global $user;
$rules = db_query("SELECT * FROM {shib_auth}");
while ($rule = db_fetch_array($rules)) {
$fieldname = $rule['field'];
$expression = '/' . $rule['regexpression'] . '/';
foreach (explode(';', $_SERVER[$fieldname]) as $value) {
if (preg_match($expression, trim($value))) {
$roles = unserialize($rule['role']);
if (!empty($roles)) {
foreach ($roles as $key => $value) {
$user->roles[$key] = $value;
}
}
}
}
}
$user->roles = array_filter($user->roles);
}