This repository has been archived by the owner on Jul 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
AM Google Apps for the VU
Remold edited this page Jul 31, 2015
·
3 revisions
/**
* This manipulation is somewhat more complex than usual. It does 3 things:
*
* 1. take the e-mail address of the user and make it the nameid value ($subjectId)
* ISSUE: https://jira.surfconext.nl/jira/browse/CONXT-111
* 2. if the schacHomeOrganization is "surfguest.nl" add '[email protected]' to
* the uid of the user
* ISSUE: https://jira.surfconext.nl/jira/browse/CONXT-143
* 3. if there are multiple email addresses, prefer the one ending in @vu.nl in a
* smart way, see below.
*/
/**
* Email address filtering
*
* The filtering has the following features:
*
* 1. prefer an address ending in @vu.nl, remove the others from the list of
* email addresses
* 2. if no email address ends in @vu.nl take the primary address (at location
* [0] (that's why there is this weird for loop going backwards and
* conditional removal only if there is > 1 address left).
* 3. make the preferred address also the nameid value ($subjectId)
*
* ISSUE: https://jira.surfconext.nl/jira/browse/CONXT-145
*/
if (isset($attributes) and ($attributes !== FALSE)) {
if (!empty($attributes['urn:mace:terena.org:attribute-def:schacHomeOrganization']) &&
$attributes['urn:mace:terena.org:attribute-def:schacHomeOrganization'][0] === "surfguest.nl") {
$subjectId = $attributes['urn:mace:dir:attribute-def:uid'][0] . '[email protected]';
} else {
if (!empty($attributes['urn:mace:dir:attribute-def:mail'][0])) {
$noOfAddresses = sizeof($attributes['urn:mace:dir:attribute-def:mail']);
if($noOfAddresses > 1) {
for($i = $noOfAddresses-1; $i >= 0; $i--) {
$result = preg_match('/.*@vu.nl$/', $attributes['urn:mace:dir:attribute-def:mail'][$i]);
if($result === 0) {
if(sizeof($attributes['urn:mace:dir:attribute-def:mail']) > 1) {
// only remove if we have more than one left
unset($attributes['urn:mace:dir:attribute-def:mail'][$i]);
}
}
sort($attributes['urn:mace:dir:attribute-def:mail']);
}
}
$subjectId = $attributes['urn:mace:dir:attribute-def:mail'][0];
}
}
}