67 if (!is_object(
$lng)) {
68 include_once
'./Services/Language/classes/class.ilLanguage.php';
74 $this->server_settings = $a_server;
100 $this->user_data = $a_data;
110 $this->new_user_auth_mode = $a_authmode;
127 if (is_array($this->modes) && !in_array($a_mode, $this->modes)) {
128 $this->modes[] = $a_mode;
139 return is_array($this->modes) && in_array($a_mode, $this->modes);
153 $rbacadmin = $DIC[
'rbacadmin'];
157 include_once
'./Services/User/classes/class.ilUserImportParser.php';
158 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
161 $importParser->setXMLContent($this->writer->xmlDumpMem(
false));
163 $importParser->setFolderId(7);
164 $importParser->startParsing();
165 $debug = $importParser->getProtocol();
166 #var_dump("<pre>",$this->writer->xmlDumpMem(),"</pre>"); 167 #print_r($this->writer->xmlDumpMem($format)); 180 $rules = $this->mapping->getRulesForUpdate();
182 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
189 $this->writer->xmlElement(
191 array(
'Id' => $role_data[
'id'],
192 'Type' => $role_data[
'type'],
193 'Action' => $role_data[
'action']),
206 include_once
'./Services/LDAP/classes/class.ilLDAPRoleAssignmentRules.php';
212 $this->writer->xmlElement(
214 array(
'Id' => $role_data[
'id'],
215 'Type' => $role_data[
'type'],
216 'Action' => $role_data[
'action']),
230 include_once(
'./Services/Xml/classes/class.ilXmlWriter.php');
232 $this->writer->xmlStartTag(
'Users');
238 foreach ($this->user_data as $external_account =>
$user) {
239 $user[
'ilExternalAccount'] = $external_account;
242 if (
$user[
'ilInternalAccount']) {
247 $this->writer->xmlStartTag(
'User', array(
'Id' => $usr_id,
'Action' =>
'Update'));
248 $this->writer->xmlElement(
'Login', array(),
$user[
'ilInternalAccount']);
249 $this->writer->xmlElement(
'ExternalAccount', array(), $external_account);
250 $this->writer->xmlElement(
'AuthMode', array(
'type' => $this->
getNewUserAuthMode()), null);
257 $rules = $this->mapping->getRulesForUpdate();
261 $this->writer->xmlStartTag(
'User', array(
'Action' =>
'Insert'));
265 $rules = $this->mapping->getRules();
268 $this->writer->xmlElement(
'Active', array(),
"true");
269 $this->writer->xmlElement(
'TimeLimitOwner', array(), 7);
270 $this->writer->xmlElement(
'TimeLimitUnlimited', array(), 1);
271 $this->writer->xmlElement(
'TimeLimitFrom', array(), time());
272 $this->writer->xmlElement(
'TimeLimitUntil', array(), time());
276 if (!
$user[
'ilInternalAccount']) {
277 $this->writer->xmlElement(
282 $this->writer->xmlElement(
'ExternalAccount', array(), $external_account);
284 foreach ($rules as $field =>
$data) {
292 switch (strtolower($value)) {
295 $this->writer->xmlElement(
'Gender', array(),
'n');
300 $this->writer->xmlElement(
'Gender', array(),
'm');
306 $this->writer->xmlElement(
'Gender', array(),
'f');
313 $this->writer->xmlElement(
'Firstname', array(), $value);
317 $this->writer->xmlElement(
'Lastname', array(), $value);
321 $this->writer->xmlElement(
'Hobby', array(), $value);
325 $this->writer->xmlElement(
'Title', array(), $value);
329 $this->writer->xmlElement(
'Institution', array(), $value);
333 $this->writer->xmlElement(
'Department', array(), $value);
337 $this->writer->xmlElement(
'Street', array(), $value);
341 $this->writer->xmlElement(
'City', array(), $value);
345 $this->writer->xmlElement(
'PostalCode', array(), $value);
349 $this->writer->xmlElement(
'Country', array(), $value);
353 $this->writer->xmlElement(
'PhoneOffice', array(), $value);
357 $this->writer->xmlElement(
'PhoneHome', array(), $value);
361 $this->writer->xmlElement(
'PhoneMobile', array(), $value);
365 $this->writer->xmlElement(
'Fax', array(), $value);
369 $this->writer->xmlElement(
'Email', array(), $value);
372 case 'matriculation':
373 $this->writer->xmlElement(
'Matriculation', array(), $value);
384 if (substr($field, 0, 4) !=
'udf_') {
387 $id_data = explode(
'_', $field);
388 if (!isset($id_data[1])) {
392 $definition = $this->udf->getDefinition($id_data[1]);
393 $this->writer->xmlElement(
395 array(
'Id' => $definition[
'il_id'],
396 'Name' => $definition[
'field_name']),
404 $this->writer->xmlEndTag(
'User');
408 $this->log->write(
'LDAP: Started creation of ' . $cnt_create .
' users.');
411 $this->log->write(
'LDAP: Started update of ' . $cnt_update .
' users.');
413 $this->writer->xmlEndTag(
'Users');
426 if (is_array($a_value)) {
443 if (strpos(
$mapping,
',') ===
false) {
450 foreach ($fields as $field) {
451 if (strlen($value)) {
456 return $value ? $value :
'';
463 include_once(
'Services/LDAP/classes/class.ilLDAPAttributeMapping.php');
469 include_once(
'Services/User/classes/class.ilUserDefinedFields.php');
static getAssignmentsForCreation($a_server_id, $a_usr_name, $a_usr_data)
static _getInstance()
Get instance.
static _getInstanceByServerId($a_server_id)
Get instance of class.
doMapping($user, $rule)
doMapping
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.
static getAssignmentsForUpdate($a_server_id, $a_usr_id, $a_usr_name, $a_usr_data)
type $ilDB type $rbacadmin type $rbacreview type $ilSetting type $ilLog
setUserData($a_data)
Set user data received from pear auth or by ldap_search.
isModeActive($a_mode)
Check if mode is active.
convertInput($a_value)
A value can be an array or a string This function converts arrays to strings.
const MODE_INITIALIZE_ROLES
__construct(ilLDAPServer $a_server)
Construct of ilLDAPAttribute2XML Defines between LDAP and ILIAS user attributes.
parseRoleAssignmentsForCreation($a_external_account, $a_user)
Parse role assignments for update of user account.
initLDAPAttributeMapping()
refresh()
Create/Update non existing users.
parseRoleAssignmentsForUpdate($a_usr_id, $a_external_account, $user)
Parse role assignments for update of user account.
getNewUserAuthMode()
Get auth mode for new users.
static getAllPossibleRoles($a_server_id)
Get all assignable roles (used for import parser)
setNewUserAuthMode($a_authmode)
Set auth mode for new users.
Update/create ILIAS user account by given LDAP attributes according to user attribute mapping setting...
getServer()
Get server settings.
addMode($a_mode)
Add import mode.
usersToXML()
Create xml string of user according to mapping rules.