Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
// #######################################################
// Author: Martin Haase / DAASI International GmbH / TextGrid
// Creation date: 2010-10-19
// Modification date: 2010-XX
// Version: 0.1
// #######################################################
include("../tglib/RBAC.class.php");
include("../tglib/WebUtils.class.php");
$configfile = "../../../config_tgwebauth.xml";
$util = new WebUtils;
$authZinstance = $_REQUEST["authZinstance"];
$remote_user = $_REQUEST["remote_user"];
if ($_REQUEST["loginmode"] == 1) {
$loginmode = TRUE;
} else {
$loginmode = FALSE;
}
if ( !(isset($authZinstance)) || strlen($authZinstance) <= 0 ) {
$util->printAuthFailure("No TgAuth Instance provided",
"Please provide a valid string in the authZinstance variable.",
null,
null );
exit;
}
$rbac = new RBAC ( $configfile, $authZinstance );
$Sid = $_REQUEST["Sid"];
$attributes = $rbac->getUserAttributes( $Sid );
$newattributes = array();
$thedisplayname = "anonymous";
//phpinfo();
foreach ($attributes as $a) {
if ($util->isBoolean($a)) {
if (isset ( $_REQUEST[$a->name]) && $_REQUEST[$a->name] == TRUE) {
$na = new StdClass();
$na->name = $a->name;
$newattributes[] = $na;
} else {
$na = new StdClass();
$na->name = $a->name;
} else if (isset ( $_REQUEST[$a->name])
&& strlen($_REQUEST[$a->name]) > 0
&& (!isset ($a->value)
|| ( isset( $a->value)
&& !($_REQUEST[$a->name] === $a->value)))) {
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
$na = new StdClass();
$na->name = $a->name;
$na->value = $_REQUEST[$a->name];
$newattributes[] = $na;
}
if ($a->name === "displayname" && isset ($a->value)) { // set Display Name
$thedisplayname = $a->value;
}
}
$res = $rbac->setAttributes($newattributes, $Sid, $loginmode );
if ((is_array($res) && $res['success'] == FALSE) || (is_object($res) && $res->result == FALSE)) {
echo "something went wrong". serialize($res);
exit;
}
if ($loginmode) {
$util->printAuthSuccess("Authentication Succeeded",
$thedisplayname,
array("remote_user" => $remote_user,
"scstatus" => "set Attributes",
"Sid" => $Sid,
"rbacbase" => $authZinstance,
"identity_provider" => "unknown",
"identified_user" => array("authnmethod" => "ePPN")
),
array("slcmode" => FALSE) // SLCs only via Shibboleth
);
} else {
$util->printSetAttributesSuccess($thedisplayname);
}
exit;
?>