64 include_once
'./Services/Language/classes/class.ilLanguage.php';
70 $this->server_settings = $a_server;
96 $this->user_data = $a_data;
106 $this->new_user_auth_mode = $a_authmode;
123 if(is_array($this->modes) && !in_array($a_mode, $this->modes))
125 $this->modes[] = $a_mode;
136 return is_array($this->modes) && in_array($a_mode, $this->modes);
152 include_once
'./Services/User/classes/class.ilUserImportParser.php';
153 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
156 $importParser->setXMLContent($this->writer->xmlDumpMem(
false));
158 $importParser->setFolderId(7);
159 $importParser->startParsing();
160 $debug = $importParser->getProtocol();
161 #var_dump("<pre>",$this->writer->xmlDumpMem(),"</pre>");
162 #print_r($this->writer->xmlDumpMem($format));
175 $rules = $this->mapping->getRulesForUpdate();
177 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
182 $user) as $role_data)
184 $this->writer->xmlElement(
'Role',
185 array(
'Id' => $role_data[
'id'],
186 'Type' => $role_data[
'type'],
187 'Action' => $role_data[
'action']),
'');
198 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
202 $a_user) as $role_data)
204 $this->writer->xmlElement(
'Role',
205 array(
'Id' => $role_data[
'id'],
206 'Type' => $role_data[
'type'],
207 'Action' => $role_data[
'action']),
'');
220 include_once(
'./Services/Xml/classes/class.ilXmlWriter.php');
222 $this->writer->xmlStartTag(
'Users');
228 foreach($this->user_data as $external_account => $user)
230 $user[
'ilExternalAccount'] = $external_account;
233 if($user[
'ilInternalAccount'])
239 $this->writer->xmlStartTag(
'User',array(
'Id' => $usr_id,
'Action' =>
'Update'));
240 $this->writer->xmlElement(
'Login',array(),$user[
'ilInternalAccount']);
241 $this->writer->xmlElement(
'ExternalAccount',array(),$external_account);
242 $this->writer->xmlElement(
'AuthMode',array(type => $this->
getNewUserAuthMode()),
null);
252 $rules = $this->mapping->getRulesForUpdate();
258 $this->writer->xmlStartTag(
'User',array(
'Action' =>
'Insert'));
262 $rules = $this->mapping->getRules();
265 $this->writer->xmlElement(
'Active',array(),
"true");
266 $this->writer->xmlElement(
'TimeLimitOwner',array(),7);
267 $this->writer->xmlElement(
'TimeLimitUnlimited',array(),1);
268 $this->writer->xmlElement(
'TimeLimitFrom',array(),time());
269 $this->writer->xmlElement(
'TimeLimitUntil',array(),time());
273 if(!$user[
'ilInternalAccount'])
275 $this->writer->xmlElement(
'AuthMode',
279 $this->writer->xmlElement(
'ExternalAccount',array(),$external_account);
281 foreach($rules as $field =>
$data)
292 switch(strtolower($value))
296 $this->writer->xmlElement(
'Gender',array(),
'm');
302 $this->writer->xmlElement(
'Gender',array(),
'f');
309 $this->writer->xmlElement(
'Firstname',array(),$value);
313 $this->writer->xmlElement(
'Lastname',array(),$value);
317 $this->writer->xmlElement(
'Hobby',array(),$value);
321 $this->writer->xmlElement(
'Title',array(),$value);
325 $this->writer->xmlElement(
'Institution',array(),$value);
329 $this->writer->xmlElement(
'Department',array(),$value);
333 $this->writer->xmlElement(
'Street',array(),$value);
337 $this->writer->xmlElement(
'City',array(),$value);
341 $this->writer->xmlElement(
'PostalCode',array(),$value);
345 $this->writer->xmlElement(
'Country',array(),$value);
349 $this->writer->xmlElement(
'PhoneOffice',array(),$value);
353 $this->writer->xmlElement(
'PhoneHome',array(),$value);
357 $this->writer->xmlElement(
'PhoneMobile',array(),$value);
361 $this->writer->xmlElement(
'Fax',array(),$value);
365 $this->writer->xmlElement(
'Email',array(),$value);
368 case 'matriculation':
369 $this->writer->xmlElement(
'Matriculation',array(),$value);
380 if(substr($field,0,4) !=
'udf_')
384 $id_data = explode(
'_',$field);
385 if(!isset($id_data[1]))
390 $definition = $this->udf->getDefinition($id_data[1]);
391 $this->writer->xmlElement(
'UserDefinedField',array(
'Id' => $definition[
'il_id'],
392 'Name' => $definition[
'field_name']),
399 $this->writer->xmlEndTag(
'User');
404 $this->log->write(
'LDAP: Started creation of '.$cnt_create.
' users.');
408 $this->log->write(
'LDAP: Started update of '.$cnt_update.
' users.');
410 $this->writer->xmlEndTag(
'Users');
423 if(is_array($a_value))
441 $mapping = trim(strtolower($rule[
'value']));
451 foreach($fields as $field)
459 return $value ? $value :
'';
466 include_once(
'Services/LDAP/classes/class.ilLDAPAttributeMapping.php');
472 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
An exception for terminatinating execution or to throw for unit testing.
static _generateLogin($a_login)
generate free login by starting with a default string and adding postfix numbers
static _getInstanceByServerId($a_server_id)
Get instance of class.
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
initLDAPAttributeMapping()
isModeActive($a_mode)
Check if mode is active.
setUserData($a_data)
Set user data received from pear auth or by ldap_search.
__construct(ilLDAPServer $a_server)
Construct of ilLDAPAttribute2XML Defines between LDAP and ILIAS user attributes.
setNewUserAuthMode($a_authmode)
Set auth mode for new users.
parseRoleAssignmentsForCreation($a_external_account, $a_user)
Parse role assignments for update of user account.
convertInput($a_value)
A value can be an array or a string This function converts arrays to strings.
const MODE_INITIALIZE_ROLES
usersToXML()
Create xml string of user according to mapping rules.
getNewUserAuthMode()
Get auth mode for new users.
addMode($a_mode)
Add import mode.
getServer()
Get server settings.
parseRoleAssignmentsForUpdate($a_usr_id, $a_external_account, $user)
Parse role assignments for update of user account.
refresh()
Create/Update non existing users.
doMapping($user, $rule)
doMapping
static getAllPossibleRoles($a_server_id)
Get all assignable roles (used for import parser)
static getAssignmentsForUpdate($a_server_id, $a_usr_id, $a_usr_name, $a_usr_data)
@global type $ilDB @global type $rbacadmin @global type $rbacreview @global type $ilSetting @global t...
static getAssignmentsForCreation($a_server_id, $a_usr_name, $a_usr_data)
static _lookupId($a_user_str)
Lookup id by login.
static _getInstance()
Get instance.