From 6e76968e958d65435fb06d71e3174ac74ae42e2a Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 1 Jul 2008 06:05:51 +0000
Subject: [PATCH] Fix group attribute generation code.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@731 44740490-163a-0410-bde0-09ae8108e29a
---
 attributealter/groups.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/attributealter/groups.php b/attributealter/groups.php
index 00d649008..acc7425c0 100644
--- a/attributealter/groups.php
+++ b/attributealter/groups.php
@@ -7,7 +7,7 @@ function getRealmPart($userid) {
 
 	$decomposedID = explode("@", $userid);
 	if (isset($decomposedID[1])) {
-		return self::encodeIllegalChars($decomposedID[1]);
+		return encodeIllegalChars($decomposedID[1]);
 	}
 	return null;
 }
@@ -20,7 +20,11 @@ function attributealter_groups(&$attributes, $spentityid = null, $idpentityid =
 	/*
 	 * Then we add the realm of the user. The part after the @ of the eduPersonPrincipalName
 	 */
-	$realmpart = getRealmPart($attributes['eduPersonPrincipalName']);
+	if(array_key_exists('eduPersonPrincipalName', $attributes)) {
+		$realmpart = getRealmPart($attributes['eduPersonPrincipalName'][0]);
+	} else {
+		$realmpart = NULL;
+	}
 	if (isset($realmpart)) {
 		$groups[] = 'realm-' . $realmpart;
 	} else {
-- 
GitLab