19 declare(strict_types=1);
43 $this->
logger = $DIC->logger()->auth();
67 return $this->int_account ===
'';
82 $importParser->setXMLContent($this->writer->xmlDumpMem(
false));
85 $importParser->setRoleAssignment($roles);
88 $importParser->startParsing();
89 $debug = $importParser->getProtocol();
102 $this->writer->xmlStartTag(
'Users');
105 $this->writer->xmlStartTag(
'User', [
'Action' =>
'Insert']);
108 $this->writer->xmlStartTag(
115 $this->writer->xmlElement(
'Login', [], $this->int_account);
118 $this->writer->xmlElement(
'ExternalAccount', array(), $this->ext_account);
119 $this->writer->xmlElement(
'AuthMode', array(
'type' => self::AUTH_MODE), null);
124 $this->writer->xmlElement(
'Active', array(),
"true");
125 $this->writer->xmlElement(
'TimeLimitOwner', array(), 7);
126 $this->writer->xmlElement(
'TimeLimitUnlimited', array(), 1);
127 $this->writer->xmlElement(
'TimeLimitFrom', array(), time());
128 $this->writer->xmlElement(
'TimeLimitUntil', array(), time());
131 foreach ($this->
settings->getProfileMappingFields() as $field => $lng_key) {
132 $connect_name = $this->
settings->getProfileMappingFieldValue($field);
133 if (!$connect_name) {
134 $this->
logger->debug(
'Ignoring unconfigured field: ' . $field);
138 $this->
logger->debug(
'Ignoring ' . $field .
' for update.');
142 $value = $this->
valueFrom($connect_name);
144 $this->
logger->debug(
'Cannot find user data in ' . $connect_name);
150 $this->writer->xmlElement(
'Firstname', [], $value);
154 $this->writer->xmlElement(
'Lastname', [], $value);
158 $this->writer->xmlElement(
'Email', [], $value);
162 $this->writer->xmlElement(
'Birthday', [], $value);
166 $this->writer->xmlEndTag(
'User');
167 $this->writer->xmlEndTag(
'Users');
169 $this->
logger->debug($this->writer->xmlDumpMem());
178 $this->
logger->debug(
'Parsing role assignments');
186 foreach ($this->
settings->getRoleMappings() as $role_id => $role_info) {
187 $this->
logger->dump($role_id);
188 $this->
logger->dump($role_info);
190 [$role_attribute, $role_value] = explode(
'::', $role_info[
'value']);
196 $this->
logger->debug(
'No valid role mapping configuration for: ' . $role_id);
200 if (!isset($this->user_info->{$role_attribute})) {
201 $this->
logger->debug(
'No user info passed');
206 $this->
logger->debug(
'No user role update for role: ' . $role_id);
210 if (is_array($this->user_info->{$role_attribute})) {
211 if (!in_array($role_value, $this->user_info->{$role_attribute},
true)) {
212 $this->
logger->debug(
'User account has no ' . $role_value);
215 } elseif (strcmp($this->user_info->{$role_attribute}, $role_value) !== 0) {
216 $this->
logger->debug(
'User account has no ' . $role_value);
219 $this->
logger->debug(
'Matching role mapping for role_id: ' . $role_id);
222 $roles_assignable[(
int) $role_id] = (
int) $role_id;
223 $long_role_id = (
'il_' .
IL_INST_ID .
'_role_' . $role_id);
225 $this->writer->xmlElement(
228 'Id' => $long_role_id,
240 $this->writer->xmlElement(
243 'Id' => $long_role_id,
250 return $roles_assignable;
253 protected function valueFrom(
string $connect_name): string
255 if (!$connect_name) {
258 if (!property_exists($this->user_info, $connect_name)) {
259 $this->
logger->debug(
'Cannot find property ' . $connect_name .
' in user info ');
263 return (
string) $this->user_info->{$connect_name};
static _generateLogin(string $a_login)
generate free login by starting with a default string and adding postfix numbers
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupId($a_user_str)
static _checkExternalAuthAccount(string $a_auth, string $a_account, bool $tryFallback=true)
check whether external account and authentication method matches with a user
setExternalAccount(string $ext_account)
setInternalAccount(string $int_account)
valueFrom(string $connect_name)
ilOpenIdConnectSettings $settings
parseRoleAssignments()
Parse role assignments.
__construct(ilOpenIdConnectSettings $settings, stdClass $user_info)