ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ilSoapUserAdministration Class Reference
+ Inheritance diagram for ilSoapUserAdministration:
+ Collaboration diagram for ilSoapUserAdministration:

Public Member Functions

 login (string $client, string $username, string $password)
 
 logout (string $sid)
 
 lookupUser (string $sid, string $user_name)
 
 importUsers (string $sid, int $folder_id, string $usr_xml, int $conflict_rule, bool $send_account_mail)
 
 getUsersForContainer (string $sid, int $ref_id, bool $attachRoles, int $active)
 
 getUserForRole (string $sid, int $role_id, bool $attachRoles, int $active)
 
 searchUser (string $sid, array $a_keyfields, string $query_operator, array $a_keyvalues, bool $attach_roles, int $active)
 return user xml following dtd 3.7 More...
 
 getUserXML (string $sid, array $a_user_ids, bool $attach_roles)
 
 hasNewMail (string $sid)
 
 getUserIdBySid (string $sid)
 
- Public Member Functions inherited from ilSoapAdministration
 __construct (bool $use_nusoap=true)
 
 getMessage ()
 
 appendMessage (string $a_str)
 
 setMessageCode (string $a_code)
 
 getMessageCode ()
 
 reInitUser ()
 
 isFault ($object)
 
 getInstallationInfoXML ()
 
 getClientInfoXML (string $clientid)
 

Data Fields

const USER_FOLDER_ID = 7
 
- Data Fields inherited from ilSoapAdministration
const NUSOAP = 1
 
const PHP5 = 2
 
int $error_method
 Defines type of error handling (PHP5 || NUSOAP) More...
 

Protected Member Functions

 isPermittedRole (int $a_folder, int $a_role)
 
- Protected Member Functions inherited from ilSoapAdministration
 checkSession (string $sid)
 
 explodeSid (string $sid)
 
 setMessage (string $a_str)
 
 initAuth (string $sid)
 
 initIlias ()
 
 initAuthenticationObject ()
 
 raiseError (string $a_message, $a_code)
 
 checkObjectAccess (int $ref_id, array $expected_type, string $permission, bool $returnObject=false)
 check access for ref id: expected type, permission, return object instance if returnobject is true More...
 

Private Member Functions

 getImportProtocolAsXML (array $a_array)
 Create XML ResultSet. More...
 
 getUserMappingAsXML (array $a_array)
 return user mapping as xml More...
 
 buildSearchQuery (array $a_keyfields, string $queryOperator, array $a_keyvalues)
 create search term according to parameters More...
 

Additional Inherited Members

- Protected Attributes inherited from ilSoapAdministration
bool $soap_check = true
 
string $message = ''
 
string $message_code = ''
 

Detailed Description

Definition at line 26 of file class.ilSoapUserAdministration.php.

Member Function Documentation

◆ buildSearchQuery()

ilSoapUserAdministration::buildSearchQuery ( array  $a_keyfields,
string  $queryOperator,
array  $a_keyvalues 
)
private

create search term according to parameters

Definition at line 722 of file class.ilSoapUserAdministration.php.

722 : string
723 {
724 global $DIC;
725
726 $ilDB = $DIC['ilDB'];
727 $query = array();
728
729 $allowed_fields = array("firstname",
730 "lastname",
731 "email",
732 "login",
733 "matriculation",
734 "institution",
735 "department",
736 "title",
737 "ext_account"
738 );
739
740 foreach ($a_keyfields as $keyfield) {
741 $keyfield = strtolower($keyfield);
742
743 if (!in_array($keyfield, $allowed_fields)) {
744 continue;
745 }
746
747 $field_query = array();
748 foreach ($a_keyvalues as $keyvalue) {
749 if (strlen($keyvalue) >= 3) {
750 $field_query [] = $ilDB->like($ilDB->quoteIdentifier($keyfield), 'text', '%' . $keyvalue . "%");
751 }
752 }
753 if (count($field_query)) {
754 $query [] = implode(" " . strtoupper($queryOperator) . " ", $field_query);
755 }
756 }
757
758 return count($query) ? " AND ((" . implode(") OR (", $query) . "))" : "AND 0";
759 }
global $DIC
Definition: shib_login.php:26

References $DIC, and $ilDB.

Referenced by searchUser().

+ Here is the caller graph for this function:

◆ getImportProtocolAsXML()

ilSoapUserAdministration::getImportProtocolAsXML ( array  $a_array)
private

Create XML ResultSet.

Definition at line 576 of file class.ilSoapUserAdministration.php.

576 : string
577 {
578 $xmlResultSet = new ilXMLResultSet();
579 $xmlResultSet->addColumn("userid");
580 $xmlResultSet->addColumn("login");
581 $xmlResultSet->addColumn("action");
582 $xmlResultSet->addColumn("message");
583
584 foreach ($a_array as $username => $messages) {
585 foreach ($messages as $message) {
586 $xmlRow = new ilXMLResultSetRow();
587 $xmlRow->setValue(0, 0);
588 $xmlRow->setValue(1, $username);
589 $xmlRow->setValue(2, "");
590 $xmlRow->setValue(3, $message);
591
592 $xmlResultSet->addRow($xmlRow);
593 }
594 }
595
596 $xml_writer = new ilXMLResultSetWriter($xmlResultSet);
597
598 if ($xml_writer->start()) {
599 return $xml_writer->getXML();
600 }
601
602 return $this->raiseError('Error in __getImportProtocolAsXML', 'Server');
603 }
raiseError(string $a_message, $a_code)
Row Class for XMLResultSet.
XML Writer for XMLResultSet.

References ilSoapAdministration\$message, and ilSoapAdministration\raiseError().

Referenced by importUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserForRole()

ilSoapUserAdministration::getUserForRole ( string  $sid,
int  $role_id,
bool  $attachRoles,
int  $active 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 503 of file class.ilSoapUserAdministration.php.

504 {
505 $this->initAuth($sid);
506 $this->initIlias();
507
508 if (!$this->checkSession($sid)) {
509 return $this->raiseError($this->getMessage(), $this->getMessageCode());
510 }
511
512 global $DIC;
513
514 $ilDB = $DIC['ilDB'];
515 $rbacreview = $DIC->rbac()->review();
516 $tree = $DIC->repositoryTree();
517 $ilUser = $DIC->user();
518 $access = $DIC->access();
519
520 $global_roles = $rbacreview->getGlobalRoles();
521
522 if (in_array($role_id, $global_roles, true)) {
523 // global roles
524 if ($role_id === SYSTEM_ROLE_ID &&
525 !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()), true)) {
526 return $this->raiseError("Role access not permitted. ($role_id)", "Server");
527 }
528 } else {
529 // local roles
530 $rolfs = $rbacreview->getFoldersAssignedToRole($role_id, true);
531 $access_granted = true;
532 foreach ($rolfs as $rolf) {
533 if ($tree->isDeleted($rolf)) {
534 $access_granted = false;
535 }
536 $type = \ilObject::_lookupType($rolf, true);
537 switch ($type) {
538 case 'crs':
539 case 'grp':
540 if (!$access->checkAccess('manage_members', '', $rolf)) {
541 $access_granted = false;
542 }
543 break;
544 default:
545 if (!$access->checkAccess('edit_permission', '', $rolf)) {
546 $access_granted = false;
547 }
548 break;
549 }
550 }
551 // read user data must be granted
552 if (!$access->checkAccess('read_users', '', self::USER_FOLDER_ID)) {
553 $access_granted = false;
554 }
555 if (!$access_granted || !count($rolfs)) {
556 return $this->raiseError('Role access not permitted. ' . '(' . $role_id . ')', 'Server');
557 }
558 }
559
560 $data = ilObjUser::_getUsersForRole($role_id, $active);
561
562 $xmlWriter = new ilUserXMLWriter();
563 $xmlWriter->setAttachRoles($attachRoles);
564
565 $xmlWriter->setObjects($data);
566
567 if ($xmlWriter->start()) {
568 return $xmlWriter->getXML();
569 }
570 return $this->raiseError('Error in getUsersForRole', 'Server');
571 }
static _getUsersForRole(int $role_id, int $active=-1)
static _lookupType(int $id, bool $reference=false)
XML writer class Class to simplify manual writing of xml documents.
const SYSTEM_ROLE_ID
Definition: constants.php:29
const USER_FOLDER_ID
Definition: constants.php:33

References $data, $DIC, $ilDB, ilObjUser\_getUsersForRole(), ilObject\_lookupType(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), SYSTEM_ROLE_ID, and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ getUserIdBySid()

ilSoapUserAdministration::getUserIdBySid ( string  $sid)
Returns
int|soap_fault|SoapFault|null

Definition at line 825 of file class.ilSoapUserAdministration.php.

826 {
827 $this->initAuth($sid);
828 $this->initIlias();
829
830 if (!$this->checkSession($sid)) {
831 return $this->raiseError($this->getMessage(), $this->getMessageCode());
832 }
833
834 global $DIC;
835
836 $ilDB = $DIC['ilDB'];
837
838 $parts = explode('::', $sid);
839 $query = "SELECT usr_id FROM usr_session "
840 . "INNER JOIN usr_data ON usr_id = user_id WHERE session_id = %s";
841 $res = $ilDB->queryF($query, array('text'), array($parts[0]));
842 $data = $ilDB->fetchAssoc($res);
843
844 if (!(int) $data['usr_id']) {
845 $this->raiseError('User does not exist', 'Client');
846 }
847 return (int) $data['usr_id'];
848 }
$res
Definition: ltiservices.php:69
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61

References $data, $DIC, $ilDB, $parts, $res, ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ getUserMappingAsXML()

ilSoapUserAdministration::getUserMappingAsXML ( array  $a_array)
private

return user mapping as xml

Parameters
array(user_id => login) $a_array

Definition at line 609 of file class.ilSoapUserAdministration.php.

610 {
611 $xmlResultSet = new ilXMLResultSet();
612 $xmlResultSet->addColumn("userid");
613 $xmlResultSet->addColumn("login");
614 $xmlResultSet->addColumn("action");
615 $xmlResultSet->addColumn("message");
616
617 if (count($a_array)) {
618 foreach ($a_array as $username => $message) {
619 $xmlRow = new ilXMLResultSetRow();
620 $xmlRow->setValue(0, $username);
621 $xmlRow->setValue(1, $message["login"]);
622 $xmlRow->setValue(2, $message["action"]);
623 $xmlRow->setValue(3, $message["message"]);
624
625 $xmlResultSet->addRow($xmlRow);
626 }
627 }
628
629 $xml_writer = new ilXMLResultSetWriter($xmlResultSet);
630
631 if ($xml_writer->start()) {
632 return $xml_writer->getXML();
633 }
634
635 return $this->raiseError('Error in __getUserMappingAsXML', 'Server');
636 }

References ilSoapAdministration\$message, and ilSoapAdministration\raiseError().

Referenced by importUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsersForContainer()

ilSoapUserAdministration::getUsersForContainer ( string  $sid,
int  $ref_id,
bool  $attachRoles,
int  $active 
)
Returns
ilObject|mixed|soap_fault|SoapFault|string|null

Definition at line 420 of file class.ilSoapUserAdministration.php.

421 {
422 $this->initAuth($sid);
423 $this->initIlias();
424
425 if (!$this->checkSession($sid)) {
426 return $this->raiseError($this->getMessage(), $this->getMessageCode());
427 }
428
429 global $DIC;
430
431 $ilDB = $DIC['ilDB'];
432 $tree = $DIC['tree'];
433 $rbacreview = $DIC['rbacreview'];
434 $rbacsystem = $DIC['rbacsystem'];
435 $access = $DIC->access();
436
437 if ($ref_id === -1) {
439 }
440
441 if (
443 !$access->checkAccess('read_users', '', self::USER_FOLDER_ID)
444 ) {
445 return $this->raiseError('Access denied', "Client");
446 }
447
448 $object = $this->checkObjectAccess($ref_id, array("crs", "cat", "grp", "usrf", "sess"), "read", true);
449 if ($this->isFault($object)) {
450 return $object;
451 }
452
453 $data = [];
454 switch ($object->getType()) {
455 case "usrf":
457 break;
458 case "cat":
460 break;
461 case "crs":
462 {
463 // GET ALL MEMBERS
464 $roles = $object->__getLocalRoles();
465
466 foreach ($roles as $role_id) {
467 $data = array_merge($rbacreview->assignedUsers($role_id), $data);
468 }
469
470 break;
471 }
472 case "grp":
473 $member_ids = $object->getGroupMemberIds();
474 $data = ilObjUser::_getUsersForGroup($member_ids, $active);
475 break;
476 case "sess":
477 $course_ref_id = $tree->checkForParentType($ref_id, 'crs');
478 if (!$course_ref_id) {
479 return $this->raiseError("No course for session", "Client");
480 }
481
482 $event_obj_id = ilObject::_lookupObjId($ref_id);
483 $event_part = new ilEventParticipants($event_obj_id);
484 $member_ids = array_keys($event_part->getParticipants());
485 $data = ilObjUser::_getUsersForIds($member_ids, $active);
486 break;
487 }
488
489 $xmlWriter = new ilUserXMLWriter();
490 $xmlWriter->setObjects($data);
491 $xmlWriter->setAttachRoles($attachRoles);
492
493 if ($xmlWriter->start()) {
494 return $xmlWriter->getXML();
495 }
496 // @todo for backward compatibility
497 return '';
498 }
class ilEventParticipants
static _getUsersForIds(array $a_mem_ids, int $active=-1, int $timelimitowner=-1)
static _getUsersForFolder(int $ref_id, int $active)
static _getUsersForGroup(array $a_mem_ids, int $active=-1)
static _lookupObjId(int $ref_id)
checkObjectAccess(int $ref_id, array $expected_type, string $permission, bool $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true
$ref_id
Definition: ltiauth.php:66

References $data, $DIC, $ilDB, $ref_id, ilObjUser\_getUsersForFolder(), ilObjUser\_getUsersForGroup(), ilObjUser\_getUsersForIds(), ilObject\_lookupObjId(), ilSoapAdministration\checkObjectAccess(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\isFault(), ilSoapAdministration\raiseError(), USER_FOLDER_ID, and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ getUserXML()

ilSoapUserAdministration::getUserXML ( string  $sid,
array  $a_user_ids,
bool  $attach_roles 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 764 of file class.ilSoapUserAdministration.php.

765 {
766 $this->initAuth($sid);
767 $this->initIlias();
768
769 if (!$this->checkSession($sid)) {
770 return $this->raiseError($this->getMessage(), $this->getMessageCode());
771 }
772
773 global $DIC;
774
775 $rbacsystem = $DIC['rbacsystem'];
776 $access = $DIC->access();
777 $ilUser = $DIC['ilUser'];
778 $ilDB = $DIC['ilDB'];
779
780 // check if own account
781 $is_self = false;
782 if (count($a_user_ids) === 1) {
783 $usr_id = (int) end($a_user_ids);
784 if ($usr_id === $ilUser->getId()) {
785 $is_self = true;
786 }
787 }
788
789 if (!$is_self && !$access->checkAccess('read_users', '', self::USER_FOLDER_ID)) {
790 return $this->raiseError('Check access failed.', 'Server');
791 }
792
793 $data = ilObjUser::_getUserData($a_user_ids);
794
795 $xmlWriter = new ilUserXMLWriter();
796 $xmlWriter->setAttachRoles($attach_roles);
797 $xmlWriter->setObjects($data);
798
799 if ($xmlWriter->start()) {
800 return $xmlWriter->getXML();
801 }
802
803 return $this->raiseError('User does not exist', 'Client');
804 }
static _getUserData(array $a_internalids)

References $data, $DIC, $ilDB, ilObjUser\_getUserData(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ILIAS\Repository\int(), ilSoapAdministration\raiseError(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ hasNewMail()

ilSoapUserAdministration::hasNewMail ( string  $sid)

Definition at line 806 of file class.ilSoapUserAdministration.php.

807 {
808 $this->initAuth($sid);
809 $this->initIlias();
810
811 if (!$this->checkSession($sid)) {
812 return $this->raiseError($this->getMessage(), $this->getMessageCode());
813 }
814
815 global $DIC;
816
817 $ilUser = $DIC['ilUser'];
818
819 return ilMailGlobalServices::getNewMailsData($ilUser)['count'] > 0;
820 }
static getNewMailsData(ilObjUser $user, int $left_interval=0)

References $DIC, ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilMailGlobalServices\getNewMailsData(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), and ilSoapAdministration\raiseError().

+ Here is the call graph for this function:

◆ importUsers()

ilSoapUserAdministration::importUsers ( string  $sid,
int  $folder_id,
string  $usr_xml,
int  $conflict_rule,
bool  $send_account_mail 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 138 of file class.ilSoapUserAdministration.php.

139 {
140 $this->initAuth($sid);
141 $this->initIlias();
142
143 if (!$this->checkSession($sid)) {
144 return $this->raiseError($this->getMessage(), $this->getMessageCode());
145 }
146
147 global $DIC;
148
149 $rbacreview = $DIC['rbacreview'];
150 $rbacsystem = $DIC['rbacsystem'];
151 $access = $DIC->access();
152 $tree = $DIC['tree'];
153 $lng = $DIC['lng'];
154 $ilUser = $DIC['ilUser'];
155 $ilLog = $DIC['ilLog'];
156
157 // validate to prevent wrong XMLs
158 $usr_xml = ltrim($usr_xml); // Remove leading whitespace (including BOM if needed)
159
160 $doc = new DOMDocument();
161 libxml_use_internal_errors(true); // Capture parsing errors
162
163 $is_loadable = $doc->loadXML($usr_xml);
164 $errors = libxml_get_errors();
165 libxml_clear_errors();
166
167 if (!$is_loadable) {
168 $msg = [];
169 foreach ($errors as $err) {
170 $msg[] = "(" . $err->line . "," . $err->column . "): " . trim($err->message);
171 }
172 libxml_clear_errors();
173 $msg = implode("\n", $msg);
174 return $this->raiseError($msg, "Client");
175 }
176
177 switch ($conflict_rule) {
178 case 2:
180 break;
181 case 3:
183 break;
184 default:
186 }
187 if ($folder_id === 0 && !$access->checkAccess('create_usr', '', self::USER_FOLDER_ID)) {
188 return $this->raiseError(
189 'Missing permission for creating/modifying users accounts' . self::USER_FOLDER_ID . ' ' . $ilUser->getId(),
190 'Server'
191 );
192 }
193
194 // folder id 0, means to check permission on user basis!
195 // must have create user right in time_limit_owner property (which is ref_id of container)
196 if ($folder_id !== 0) {
197 // determine where to import
198 if ($folder_id === -1) {
199 $folder_id = self::USER_FOLDER_ID;
200 }
201
202 // get folder
203 $import_folder = ilObjectFactory::getInstanceByRefId($folder_id, false);
204 // id does not exist
205 if (!$import_folder) {
206 return $this->raiseError('Wrong reference id.', 'Server');
207 }
208
209 // folder is not a folder, can also be a category
210 if ($import_folder->getType() !== "usrf" && $import_folder->getType() !== "cat") {
211 return $this->raiseError('Folder must be a usr folder or a category.', 'Server');
212 }
213
214 // check access to folder
215 if (!$rbacsystem->checkAccess('create_usr', $folder_id)) {
216 return $this->raiseError(
217 'Missing permission for creating users within ' . $import_folder->getTitle(),
218 'Server'
219 );
220 }
221 }
222
223 // first verify
224 $importParser = new ilUserImportParser("", ilUserImportParser::IL_VERIFY, $conflict_rule);
225 $importParser->setUserMappingMode(ilUserImportParser::IL_USER_MAPPING_ID);
226 $importParser->setXMLContent($usr_xml);
227 $importParser->startParsing();
228
229 switch ($importParser->getErrorLevel()) {
231 break;
233 return $this->getImportProtocolAsXML($importParser->getProtocol());
234 break;
236 return $this->getImportProtocolAsXML($importParser->getProtocol());
237 }
238
239 // verify is ok, so get role assignments
240
241 $importParser = new ilUserImportParser("", ilUserImportParser::IL_EXTRACT_ROLES, $conflict_rule);
242 $importParser->setXMLContent($usr_xml);
243 $importParser->setUserMappingMode(ilUserImportParser::IL_USER_MAPPING_ID);
244 $importParser->startParsing();
245
246 $roles = $importParser->getCollectedRoles();
247
248 //print_r($roles);
249
250 // roles to be assigned, skip if one is not allowed!
251 $permitted_roles = array();
252 foreach ($roles as $role_id => $role) {
253 if (!is_numeric($role_id)) {
254 // check if internal id
255 $internalId = ilUtil::__extractId($role_id, IL_INST_ID);
256
257 if (is_numeric($internalId) && $internalId > 0) {
258 $role_id = $internalId;
259 $role_name = $role_id;
260 }
261 }
262
263 if ($this->isPermittedRole($folder_id, $role_id)) {
264 $permitted_roles[$role_id] = $role_id;
265 } else {
266 $role_name = ilObject::_lookupTitle($role_id);
267 return $this->raiseError(
268 "Could not find role " . $role_name . ". Either you use an invalid/deleted role " .
269 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",
270 'Server'
271 );
272 }
273 }
274
275 $global_roles = $rbacreview->getGlobalRoles();
276
277 //print_r ($global_roles);
278
279 foreach ($permitted_roles as $role_id => $role_name) {
280 if ($role_id != "") {
281 if (in_array($role_id, $global_roles)) {
282 if (
283 (
284 $folder_id !== 0 &&
285 $folder_id !== self::USER_FOLDER_ID &&
287 ) ||
288 (
289 $role_id == SYSTEM_ROLE_ID &&
290 !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()), true)
291 )
292 ) {
293 return $this->raiseError(
294 $lng->txt("usrimport_with_specified_role_not_permitted") . " $role_name ($role_id)",
295 'Server'
296 );
297 }
298 } else {
299 $rolf = $rbacreview->getFoldersAssignedToRole($role_id, true);
300 if ($rbacreview->isDeleted($rolf[0])
301 || !$rbacsystem->checkAccess('write', $rolf[0])) {
302 return $this->raiseError(
303 $lng->txt("usrimport_with_specified_role_not_permitted") . " $role_name ($role_id)",
304 "Server"
305 );
306 }
307 }
308 }
309 }
310
311 //print_r ($permitted_roles);
312
313 $importParser = new ilUserImportParser("", ilUserImportParser::IL_USER_IMPORT, $conflict_rule);
314 $importParser->setSendMail($send_account_mail);
315 $importParser->setUserMappingMode(ilUserImportParser::IL_USER_MAPPING_ID);
316 $importParser->setFolderId($folder_id);
317 $importParser->setXMLContent($usr_xml);
318
319 $importParser->setRoleAssignment($permitted_roles);
320
321 $importParser->startParsing();
322
323 if ($importParser->getErrorLevel() !== ilUserImportParser::IL_IMPORT_FAILURE) {
324 return $this->getUserMappingAsXML($importParser->getUserMapping());
325 }
326 return $this->getImportProtocolAsXML($importParser->getProtocol());
327 }
static _getAssignUsersStatus(int $a_role_id)
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupTitle(int $obj_id)
isPermittedRole(int $a_folder, int $a_role)
getImportProtocolAsXML(array $a_array)
Create XML ResultSet.
getUserMappingAsXML(array $a_array)
return user mapping as xml
static __extractId(string $ilias_id, int $inst_id)
extract ref id from role title, e.g.
const IL_INST_ID
Definition: constants.php:40
global $lng
Definition: privfeed.php:31

References $DIC, $lng, ilUtil\__extractId(), ilObjRole\_getAssignUsersStatus(), ilObject\_lookupTitle(), ilSoapAdministration\checkSession(), getImportProtocolAsXML(), ilObjectFactory\getInstanceByRefId(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), getUserMappingAsXML(), ilUserImportParser\IL_EXTRACT_ROLES, ilUserImportParser\IL_FAIL_ON_CONFLICT, ilUserImportParser\IL_IGNORE_ON_CONFLICT, ilUserImportParser\IL_IMPORT_FAILURE, ilUserImportParser\IL_IMPORT_SUCCESS, ilUserImportParser\IL_IMPORT_WARNING, IL_INST_ID, ilUserImportParser\IL_UPDATE_ON_CONFLICT, ilUserImportParser\IL_USER_IMPORT, ilUserImportParser\IL_USER_MAPPING_ID, ilUserImportParser\IL_VERIFY, ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), isPermittedRole(), ilSoapAdministration\raiseError(), SYSTEM_ROLE_ID, USER_FOLDER_ID, and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ isPermittedRole()

ilSoapUserAdministration::isPermittedRole ( int  $a_folder,
int  $a_role 
)
protected

Definition at line 329 of file class.ilSoapUserAdministration.php.

330 {
331 static $checked_roles = array();
332 static $global_roles = null;
333
334 if (isset($checked_roles[$a_role])) {
335 return $checked_roles[$a_role];
336 }
337
338 global $DIC;
339
340 $rbacsystem = $DIC['rbacsystem'];
341 $rbacreview = $DIC['rbacreview'];
342 $ilUser = $DIC['ilUser'];
343 $tree = $DIC['tree'];
344 $ilLog = $DIC['ilLog'];
345
346 $locations = $rbacreview->getFoldersAssignedToRole($a_role, true);
347 $location = $locations[0];
348
349 // global role
350 if ($location == ROLE_FOLDER_ID) {
351 $ilLog->write(__METHOD__ . ': Check global role');
352 // check assignment permission if called from local admin
353
354 if ($a_folder !== self::USER_FOLDER_ID && $a_folder !== 0) {
355 $ilLog->write(__METHOD__ . ': ' . $a_folder);
356 if (!ilObjRole::_getAssignUsersStatus($a_role)) {
357 $ilLog->write(__METHOD__ . ': No assignment allowed');
358 $checked_roles[$a_role] = false;
359 return false;
360 }
361 }
362 // exclude anonymous role from list
363 if ($a_role === ANONYMOUS_ROLE_ID) {
364 $ilLog->write(__METHOD__ . ': Anonymous role chosen.');
365 $checked_roles[$a_role] = false;
366 return false;
367 }
368 // do not allow to assign users to administrator role if current user does not has SYSTEM_ROLE_ID
369 if ($a_role === SYSTEM_ROLE_ID &&
370 !in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()), true)) {
371 $ilLog->write(__METHOD__ . ': System role assignment forbidden.');
372 $checked_roles[$a_role] = false;
373 return false;
374 }
375
376 // Global role assignment ok
377 $ilLog->write(__METHOD__ . ': Assignment allowed.');
378 $checked_roles[$a_role] = true;
379 return true;
380 } elseif ($location) {
381 $ilLog->write(__METHOD__ . ': Check local role.');
382
383 // It's a local role
384 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role, true);
385 $rolf = $rolfs[0];
386
387 // only process role folders that are not set to status "deleted"
388 // and for which the user has write permissions.
389 // We also don't show the roles which are in the ROLE_FOLDER_ID folder.
390 // (The ROLE_FOLDER_ID folder contains the global roles).
391 if ($rbacreview->isDeleted($rolf)
392 || !$rbacsystem->checkAccess('edit_permission', $rolf)) {
393 $ilLog->write(__METHOD__ . ': Role deleted or no permission.');
394 $checked_roles[$a_role] = false;
395 return false;
396 }
397 // A local role is only displayed, if it is contained in the subtree of
398 // the localy administrated category. If the import function has been
399 // invoked from the user folder object, we show all local roles, because
400 // the user folder object is considered the parent of all local roles.
401 // Thus, if we start from the user folder object, we initializ$isInSubtree = $folder_id == USER_FOLDER_ID || $folder_id == 0;e the
402 // isInSubtree variable with true. In all other cases it is initialized
403 // with false, and only set to true if we find the object id of the
404 // locally administrated category in the tree path to the local role.
405 if ($a_folder !== self::USER_FOLDER_ID && $a_folder !== 0 && !$tree->isGrandChild($a_folder, $rolf)) {
406 $ilLog->write(__METHOD__ . ': Not in path of category.');
407 $checked_roles[$a_role] = false;
408 return false;
409 }
410 $ilLog->write(__METHOD__ . ': Assignment allowed.');
411 $checked_roles[$a_role] = true;
412 return true;
413 }
414 return false;
415 }
$location
Definition: buildRTE.php:22
const ANONYMOUS_ROLE_ID
Definition: constants.php:28
const ROLE_FOLDER_ID
Definition: constants.php:34

References $DIC, $location, ilObjRole\_getAssignUsersStatus(), ANONYMOUS_ROLE_ID, ROLE_FOLDER_ID, SYSTEM_ROLE_ID, and USER_FOLDER_ID.

Referenced by importUsers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ login()

ilSoapUserAdministration::login ( string  $client,
string  $username,
string  $password 
)
Returns
soap_fault|SoapFault|string|null

Definition at line 33 of file class.ilSoapUserAdministration.php.

34 {
35 unset($_COOKIE[session_name()]);
36 $_COOKIE['ilClientId'] = $client;
37
38 try {
39 $this->initIlias();
40 } catch (Exception $e) {
41 return $this->raiseError($e->getMessage(), 'Server');
42 }
43
44 // now try authentication
45 $credentials = new ilAuthFrontendCredentials();
46 $credentials->setUsername($username);
47 $credentials->setPassword($password);
48
49 $provider_factory = new ilAuthProviderFactory();
50 $providers = $provider_factory->getProviders($credentials);
51
52 $status = ilAuthStatus::getInstance();
53
54 $frontend_factory = new ilAuthFrontendFactory();
55 $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_WS);
56 $frontend = $frontend_factory->getFrontend(
57 $GLOBALS['DIC']['ilAuthSession'],
58 $status,
59 $credentials,
60 $providers
61 );
62
63 $frontend->authenticate();
64
65 switch ($status->getStatus()) {
67 ilLoggerFactory::getLogger('auth')->debug('Authentication successful.');
68 return $GLOBALS['DIC']['ilAuthSession']->getId() . '::' . $client;
69
70 default:
72 return $this->raiseError(
73 $status->getReason(),
74 'Server'
75 );
76 }
77 }
const int STATUS_AUTHENTICATION_FAILED
const int STATUS_AUTHENTICATED
static getInstance()
Get status instance.
static getLogger(string $a_component_id)
Get component logger.
$client
$GLOBALS["DIC"]
Definition: wac.php:54
$_COOKIE[session_name()]
Definition: xapitoken.php:52

References $_COOKIE, $client, Vendor\Package\$e, $GLOBALS, ilAuthFrontendFactory\CONTEXT_WS, ilAuthStatus\getInstance(), ilLoggerFactory\getLogger(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), ilAuthStatus\STATUS_AUTHENTICATED, and ilAuthStatus\STATUS_AUTHENTICATION_FAILED.

+ Here is the call graph for this function:

◆ logout()

ilSoapUserAdministration::logout ( string  $sid)
Returns
bool|soap_fault|SoapFault|null

Definition at line 82 of file class.ilSoapUserAdministration.php.

83 {
84 $this->initAuth($sid);
85 $this->initIlias();
86
87 if (!$this->checkSession($sid)) {
88 return $this->raiseError($this->getMessage(), $this->getMessageCode());
89 }
90
92 $GLOBALS['DIC']['ilAuthSession']->logout();
93 return true;
94 }
static setClosingContext(int $a_context)
set closing context (for statistics)
const int SESSION_CLOSE_USER

References $GLOBALS, ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), ilSession\SESSION_CLOSE_USER, and ilSession\setClosingContext().

+ Here is the call graph for this function:

◆ lookupUser()

ilSoapUserAdministration::lookupUser ( string  $sid,
string  $user_name 
)
Returns
int|soap_fault|SoapFault|null

Definition at line 99 of file class.ilSoapUserAdministration.php.

100 {
101 $this->initAuth($sid);
102 $this->initIlias();
103
104 if (!$this->checkSession($sid)) {
105 return $this->raiseError($this->getMessage(), $this->getMessageCode());
106 }
107
108 $user_name = trim($user_name);
109
110 if ($user_name === '') {
111 return $this->raiseError('No username given. Aborting', 'Client');
112 }
113
114 global $DIC;
115
116 $ilUser = $DIC->user();
117 $access = $DIC->access();
118
119 if (
120 strcasecmp($ilUser->getLogin(), $user_name) !== 0 &&
121 !$access->checkAccess(
122 'read_users',
123 '',
125 )
126 ) {
127 return $this->raiseError('Check access failed. ' . self::USER_FOLDER_ID, 'Server');
128 }
129
131
132 return $user_id;
133 }
static getUserIdByLogin(string $a_login)

References $DIC, $user_id, ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilObjUser\getUserIdByLogin(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

◆ searchUser()

ilSoapUserAdministration::searchUser ( string  $sid,
array  $a_keyfields,
string  $query_operator,
array  $a_keyvalues,
bool  $attach_roles,
int  $active 
)

return user xml following dtd 3.7

Parameters
string$sidsession id
array$a_keyfieldsarray of user fieldname, following dtd 3.7
string$queryOperatorany logical operator
array$a_keyValuesvalues separated by space, at least 3 chars per search term
bool
int
Returns
soap_fault|SoapFault|null|string

Definition at line 648 of file class.ilSoapUserAdministration.php.

655 {
656 $this->initAuth($sid);
657 $this->initIlias();
658
659 if (!$this->checkSession($sid)) {
660 return $this->raiseError($this->getMessage(), $this->getMessageCode());
661 }
662
663 global $DIC;
664
665 $ilDB = $DIC['ilDB'];
666 $access = $DIC->access();
667
668 if (!$access->checkAccess('read_users', '', self::USER_FOLDER_ID)) {
669 return $this->raiseError('Check access failed.', 'Server');
670 }
671 if (!count($a_keyfields)) {
672 $this->raiseError('At least one keyfield is needed', 'Client');
673 }
674
675 if (!count($a_keyvalues)) {
676 $this->raiseError('At least one keyvalue is needed', 'Client');
677 }
678
679 if (strcasecmp($query_operator, "and") !== 0 || strcasecmp($query_operator, "or") !== 0) {
680 $this->raiseError('Query operator must be either \'and\' or \'or\'', 'Client');
681 }
682
683 $query = $this->buildSearchQuery($a_keyfields, $query_operator, $a_keyvalues);
684
685 $query = "SELECT usr_data.*, usr_pref.value AS language
686 FROM usr_data
687 LEFT JOIN usr_pref
688 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = " .
689 $ilDB->quote("language", "text") .
690 " WHERE 1 = 1 " . $query;
691
692 if ($active > -1) {
693 $query .= " AND active = " . $ilDB->quote($active);
694 }
695
696 $query .= " ORDER BY usr_data.lastname, usr_data.firstname ";
697
698 //echo $query;
699
700 $r = $ilDB->query($query);
701
702 $data = array();
703
704 while ($row = $ilDB->fetchAssoc($r)) {
705 $data[] = $row;
706 }
707
708 $xmlWriter = new ilUserXMLWriter();
709 $xmlWriter->setAttachRoles($attach_roles);
710
711 $xmlWriter->setObjects($data);
712
713 if ($xmlWriter->start()) {
714 return $xmlWriter->getXML();
715 }
716 return $this->raiseError('Error in searchUser', 'Server');
717 }
buildSearchQuery(array $a_keyfields, string $queryOperator, array $a_keyvalues)
create search term according to parameters

References $data, $DIC, $ilDB, buildSearchQuery(), ilSoapAdministration\checkSession(), ilSoapAdministration\getMessage(), ilSoapAdministration\getMessageCode(), ilSoapAdministration\initAuth(), ilSoapAdministration\initIlias(), ilSoapAdministration\raiseError(), and USER_FOLDER_ID.

+ Here is the call graph for this function:

Field Documentation

◆ USER_FOLDER_ID

const ilSoapUserAdministration::USER_FOLDER_ID = 7

Definition at line 28 of file class.ilSoapUserAdministration.php.

Referenced by getUsersForContainer(), and importUsers().


The documentation for this class was generated from the following file: