59 $this->logger = $DIC->logger()->auth();
97 return strlen($this->int_account) == 0;
113 $importParser->setXMLContent($this->writer->xmlDumpMem(
false));
116 $importParser->setRoleAssignment($roles);
119 $importParser->startParsing();
120 $debug = $importParser->getProtocol();
137 $this->writer->xmlStartTag(
'Users');
140 $this->writer->xmlStartTag(
'User', [
'Action' =>
'Insert']);
143 $this->writer->xmlStartTag(
150 $this->writer->xmlElement(
'Login', [], $this->int_account);
153 $this->writer->xmlElement(
'ExternalAccount', array(), $this->ext_account);
154 $this->writer->xmlElement(
'AuthMode', array(
'type' => self::AUTH_MODE), null);
159 $this->writer->xmlElement(
'Active', array(),
"true");
160 $this->writer->xmlElement(
'TimeLimitOwner', array(), 7);
161 $this->writer->xmlElement(
'TimeLimitUnlimited', array(), 1);
162 $this->writer->xmlElement(
'TimeLimitFrom', array(), time());
163 $this->writer->xmlElement(
'TimeLimitUntil', array(), time());
166 foreach ($this->
settings->getProfileMappingFields() as $field => $lng_key) {
167 $connect_name = $this->
settings->getProfileMappingFieldValue($field);
168 if (!$connect_name) {
169 $this->logger->debug(
'Ignoring unconfigured field: ' . $field);
173 $this->logger->debug(
'Ignoring ' . $field .
' for update.');
177 $value = $this->
valueFrom($connect_name);
178 if (!strlen($value)) {
179 $this->logger->debug(
'Cannot find user data in ' . $connect_name);
185 $this->writer->xmlElement(
'Firstname', [], $value);
189 $this->writer->xmlElement(
'Lastname', [], $value);
193 $this->writer->xmlElement(
'Email', [], $value);
197 $this->writer->xmlElement(
'Birthday', [], $value);
201 $this->writer->xmlEndTag(
'User');
202 $this->writer->xmlEndTag(
'Users');
204 $this->logger->debug($this->writer->xmlDumpMem());
213 $this->logger->debug(
'Parsing role assignments');
222 foreach ($this->
settings->getRoleMappings() as $role_id => $role_info) {
223 $this->logger->dump($role_id);
224 $this->logger->dump($role_info);
226 list($role_attribute, $role_value) = explode(
'::', $role_info[
'value']);
232 $this->logger->debug(
'No valid role mapping configuration for: ' . $role_id);
236 if (!isset($this->user_info->$role_attribute)) {
237 $this->logger->debug(
'No user info passed');
243 !$role_info[
'update']
245 $this->logger->debug(
'No user role update for role: ' . $role_id);
249 if (is_array($this->user_info->$role_attribute)) {
250 if (!in_array($role_value, $this->user_info->$role_attribute)) {
251 $this->logger->debug(
'User account has no ' . $role_value);
254 } elseif (strcmp($this->user_info->$role_attribute, $role_value) !== 0) {
255 $this->logger->debug(
'User account has no ' . $role_value);
258 $this->logger->debug(
'Matching role mapping for role_id: ' . $role_id);
261 $roles_assignable[$role_id] = $role_id;
262 $long_role_id = (
'il_' . IL_INST_ID .
'_role_' . $role_id);
264 $this->writer->xmlElement(
267 'Id' => $long_role_id,
276 $long_role_id = (
'il_' . IL_INST_ID .
'_role_' . $this->
settings->getRole());
279 $this->writer->xmlElement(
282 'Id' => $long_role_id,
289 return $roles_assignable;
296 protected function valueFrom(
string $connect_name) : string
298 if (!$connect_name) {
301 if (!property_exists($this->user_info, $connect_name)) {
302 $this->logger->debug(
'Cannot find property ' . $connect_name .
' in user info ');
305 $val = $this->user_info->$connect_name;
Class ilOpenIdConnectSettingsGUI.
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
static _lookupId($a_user_str)
Lookup id by login.
setExternalAccount(string $ext_account)
setInternalAccount(string $int_account)
valueFrom(string $connect_name)
Class ilOpenIdConnectSettingsGUI.
parseRoleAssignments()
Parse role assignments.
static _checkExternalAuthAccount($a_auth, $a_account, $tryFallback=true)
check whether external account and authentication method matches with a user
Class ilOpenIdConnectSettingsGUI.
transformToXml()
transform user data to xml
const USER_FOLDER_ID
Class ilObjUserFolder.
__construct(\ilOpenIdConnectSettings $settings, $user_info)
ilOpenIdConnectUserSync constructor.