Skip to content

Instantly share code, notes, and snippets.

@baszoetekouw
Created July 4, 2017 09:20
Show Gist options
  • Save baszoetekouw/7f830d756e1a6ab7e4fc06a6f7848cf1 to your computer and use it in GitHub Desktop.
Save baszoetekouw/7f830d756e1a6ab7e4fc06a6f7848cf1 to your computer and use it in GitHub Desktop.
OpenConext Attribute manipulation to reconstruct sHO+uid from ePPN
# This attribute manipulation reconstructs a uid and schacHomeOrg
# from an EPPN
$attr_eppn_saml1 = "urn:mace:dir:attribute-def:eduPersonPrincipalName";
$attr_eppn_saml2 = "urn:oid:1.3.6.1.4.1.5923.1.1.1.6";
$attr_uid = "urn:mace:dir:attribute-def:uid";
$attr_sho = "urn:mace:terena.org:attribute-def:schacHomeOrganization";
if ( isset($attributes)
and ($attributes !== FALSE)
and !empty($attributes[$attr_eppn_saml1][0])
and ( empty($attributes[$attr_uid][0]) or empty($attributes[$attr_sho][0]) )
)
{
$fields = explode("@", $attributes[$attr_eppn_saml1][0], 2 );
if ( count($fields)==2 and !empty($fields[0]) and !empty($fields[1]) )
{
$attributes[$attr_uid] = array( $fields[0] );
$attributes[$attr_sho] = array( $fields[1] );
}
}
# and the same, now for the oid-variant of the attribute
if ( isset($attributes)
and ($attributes !== FALSE)
and !empty($attributes[$attr_eppn_saml2][0])
and ( empty($attributes[$attr_uid][0]) or empty($attributes[$attr_sho][0]) )
)
{
$fields = explode("@", $attributes[$attr_eppn_saml2][0], 2 );
if ( count($fields)==2 and !empty($fields[0]) and !empty($fields[1]) )
{
$attributes[$attr_uid] = array( $fields[0] );
$attributes[$attr_sho] = array( $fields[1] );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment