33 include_once
'./webservice/soap/classes/class.ilSoapAdministration.php';
46 public function login(
$client,$username,$password)
66 include_once
'./Services/Authentication/classes/Frontend/class.ilAuthFrontendCredentials.php';
68 $credentials->setUsername($username);
69 $credentials->setPassword($password);
71 include_once
'./Services/Authentication/classes/Provider/class.ilAuthProviderFactory.php';
73 $providers = $provider_factory->getProviders($credentials);
75 include_once
'./Services/Authentication/classes/class.ilAuthStatus.php';
78 include_once
'./Services/Authentication/classes/Frontend/class.ilAuthFrontendFactory.php';
81 $frontend = $frontend_factory->getFrontend(
88 $frontend->authenticate();
90 switch($status->getStatus())
100 $status->getReason(),
111 $this->sauth->setClient(
$client);
112 $this->sauth->setUsername($username);
113 $this->sauth->setPT($PT);
114 $authenticated =
true;
117 if(!$this->sauth->authenticate())
119 $authenticated =
false;
123 return $this->
__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
125 return $this->sauth->getSid().
'::'.
$client;
139 return $this->login(
$client, $username, $password);
157 if(!$this->__checkSession($sid))
162 if (!$ilIliasIniFile->readVariable(
'server',
'studip'))
164 return $this->
__raiseError(
'Stud.IP mode not active.',
'Server');
167 if(!$rbacreview->isAssigned($ilUser->getId(),SYSTEM_ROLE_ID))
169 return $this->
__raiseError(
'No permission to initialize user session.',
'Server');
172 if($ilUser->getLoginByUserId($user_id))
175 include_once
'./Services/Authentication/classes/class.ilSession.php';
177 $GLOBALS[
'DIC'][
'ilAuthSession']->logout();
182 $GLOBALS[
'DIC'][
'ilAuthSession']->init();
183 $GLOBALS[
'DIC'][
'ilAuthSession']->setAuthenticated(
true, $user_id);
184 return (session_id().
'::'.
$client);
186 return $this->
__raiseError(
'User does not exist',
'Client');
199 if(!$this->__checkSession($sid))
204 include_once
'./Services/Authentication/classes/class.ilSession.php';
206 $GLOBALS[
'DIC'][
'ilAuthSession']->logout();
215 if(!$this->__checkSession($sid))
220 $user_name = trim($user_name);
222 if(!strlen($user_name))
224 return $this->
__raiseError(
'No username given. Aborting',
'Client');
229 if(strcasecmp($ilUser->getLogin(), $user_name) != 0 && !$rbacsystem->checkAccess(
'read',
USER_FOLDER_ID))
237 return $user_id ? $user_id :
"0";
246 if(!$this->__checkSession($sid))
255 return $this->
__raiseError(
'Check access failed.',
'Server');
258 if($ilUser->getLoginByUserId($user_id))
265 return $this->
__raiseError(
'User does not exist',
'Client');
277 if(!$this->__checkSession($sid))
284 return $this->
__raiseError(
'No user_id given. Aborting',
'Client');
291 return $this->
__raiseError(
'Check access failed.',
'Server');
294 if(!$ilUser->getLoginByUserId($user_id))
296 return $this->
__raiseError(
'User id: '.$user_id.
' is not a valid identifier. Aborting',
'Client');
298 if($ilUser->getId() == $user_id)
300 return $this->
__raiseError(
'Cannot delete myself. Aborting',
'Client');
302 if($user_id == SYSTEM_USER_ID)
304 return $this->
__raiseError(
'Cannot delete root account. Aborting',
'Client');
307 $log->write(
'SOAP: deleteUser()');
309 $delete_user->delete();
316 $usr_data[
'usr_id'] = $usr_obj->getId();
317 $usr_data[
'login'] = $usr_obj->getLogin();
318 $usr_data[
'passwd'] = $usr_obj->getPasswd();
319 $usr_data[
'passwd_type'] = $usr_obj->getPasswdType();
320 $usr_data[
'firstname'] = $usr_obj->getFirstname();
321 $usr_data[
'lastname'] = $usr_obj->getLastname();
322 $usr_data[
'title'] = $usr_obj->getUTitle();
323 $usr_data[
'gender'] = $usr_obj->getGender();
324 $usr_data[
'email'] = $usr_obj->getEmail();
325 $usr_data[
'institution'] = $usr_obj->getInstitution();
326 $usr_data[
'street'] = $usr_obj->getStreet();
327 $usr_data[
'city'] = $usr_obj->getCity();
328 $usr_data[
'zipcode'] = $usr_obj->getZipcode();
329 $usr_data[
'country'] = $usr_obj->getCountry();
330 $usr_data[
'phone_office'] = $usr_obj->getPhoneOffice();
331 $usr_data[
'last_login'] = $usr_obj->getLastLogin();
332 $usr_data[
'last_update'] = $usr_obj->getLastUpdate();
333 $usr_data[
'create_date'] = $usr_obj->getCreateDate();
334 $usr_data[
'hobby'] = $usr_obj->getHobby();
335 $usr_data[
'department'] = $usr_obj->getDepartment();
336 $usr_data[
'phone_home'] = $usr_obj->getPhoneHome();
337 $usr_data[
'phone_mobile'] = $usr_obj->getPhoneMobile();
338 $usr_data[
'fax'] = $usr_obj->getFax();
339 $usr_data[
'time_limit_owner'] = $usr_obj->getTimeLimitOwner();
340 $usr_data[
'time_limit_unlimited'] = $usr_obj->getTimeLimitUnlimited();
341 $usr_data[
'time_limit_from'] = $usr_obj->getTimeLimitFrom();
342 $usr_data[
'time_limit_until'] = $usr_obj->getTimeLimitUntil();
343 $usr_data[
'time_limit_message'] = $usr_obj->getTimeLimitMessage();
344 $usr_data[
'referral_comment'] = $usr_obj->getComment();
345 $usr_data[
'matriculation'] = $usr_obj->getMatriculation();
346 $usr_data[
'active'] = $usr_obj->getActive();
347 $usr_data[
'approve_date'] = $usr_obj->getApproveDate();
348 $usr_data[
'user_skin'] = $usr_obj->getPref(
'skin');
349 $usr_data[
'user_style'] = $usr_obj->getPref(
'style');
350 $usr_data[
'user_language'] = $usr_obj->getLanguage();
351 $usr_data[
'auth_mode'] = $usr_obj->getAuthMode();
352 $usr_data[
'accepted_agreement'] = !$usr_obj->hasToAcceptTermsOfService();
353 $usr_data[
'import_id'] = $usr_obj->getImportId();
364 function importUsers ($sid, $folder_id, $usr_xml, $conflict_rule, $send_account_mail)
369 if(!$this->__checkSession($sid))
375 include_once
'./Services/User/classes/class.ilUserImportParser.php';
376 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
377 include_once
'./Services/Object/classes/class.ilObjectFactory.php';
391 foreach (
$error as $err) {
392 $msg []=
"(".$err[
"line"].
",".$err[
"col"].
"): ".$err[
"errormessage"];
399 $msg = join(
"\n",$msg);
404 switch ($conflict_rule)
422 if ($folder_id == -1)
429 return $this->
__raiseError(
'Wrong reference id.',
'Server');
432 if ($import_folder->getType() !=
"usrf" && $import_folder->getType() !=
"cat")
433 return $this->
__raiseError(
'Folder must be a usr folder or a category.',
'Server');
436 if(!$rbacsystem->checkAccess(
'create_usr',$folder_id))
438 return $this->
__raiseError(
'Missing permission for creating users within '.$import_folder->getTitle(),
'Server');
447 $importParser->setXMLContent($usr_xml);
448 $importParser->startParsing();
450 switch ($importParser->getErrorLevel())
464 $importParser->setXMLContent($usr_xml);
466 $importParser->startParsing();
468 $roles = $importParser->getCollectedRoles();
475 $permitted_roles =
array();
476 foreach ($roles as $role_id => $role)
478 if (!is_numeric ($role_id))
483 if (is_numeric($internalId))
485 $role_id = $internalId;
486 $role_name = $role_id;
498 $permitted_roles[$role_id] = $role_id;
503 return $this->
__raiseError(
"Could not find role ".$role_name.
". Either you use an invalid/deleted role ".
504 "or you try to assign a local role into the non-standard user folder and this role is not in its subtree.",
'Server');
508 $global_roles = $rbacreview->getGlobalRoles();
514 foreach ($permitted_roles as $role_id => $role_name)
518 if (in_array($role_id, $global_roles))
520 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId()))
524 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
'Server');
529 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
530 if ($rbacreview->isDeleted($rolf[0])
531 || ! $rbacsystem->checkAccess(
'write',$rolf[0]))
534 return $this->
__raiseError($lng->txt(
"usrimport_with_specified_role_not_permitted").
" $role_name ($role_id)",
"Server");
543 $importParser->setSendMail($send_account_mail);
545 $importParser->setFolderId($folder_id);
546 $importParser->setXMLContent($usr_xml);
548 $importParser->setRoleAssignment($permitted_roles);
550 $importParser->startParsing();
569 static $checked_roles =
array();
570 static $global_roles = null;
573 if(isset($checked_roles[$a_role]))
575 return $checked_roles[$a_role];
580 $locations = $rbacreview->getFoldersAssignedToRole($a_role,
true);
586 $ilLog->write(__METHOD__.
': Check global role');
592 $ilLog->write(__METHOD__.
': '.$a_folder);
593 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
596 $ilLog->write(__METHOD__.
': No assignment allowed');
597 $checked_roles[$a_role] =
false;
602 if ($a_role == ANONYMOUS_ROLE_ID)
604 $ilLog->write(__METHOD__.
': Anonymous role chosen.');
605 $checked_roles[$a_role] =
false;
609 if($a_role == SYSTEM_ROLE_ID
and !in_array(SYSTEM_ROLE_ID,$rbacreview->assignedRoles($ilUser->getId())))
611 $ilLog->write(__METHOD__.
': System role assignment forbidden.');
612 $checked_roles[$a_role] =
false;
617 $ilLog->write(__METHOD__.
': Assignment allowed.');
618 $checked_roles[$a_role] =
true;
623 $ilLog->write(__METHOD__.
': Check local role.');
626 $rolfs = $rbacreview->getFoldersAssignedToRole($a_role,
true);
634 if($rbacreview->isDeleted($rolf)
635 || !$rbacsystem->checkAccess(
'edit_permission',$rolf))
637 $ilLog->write(__METHOD__.
': Role deleted or no permission.');
638 $checked_roles[$a_role] =
false;
651 $ilLog->write(__METHOD__.
': Not in path of category.');
652 $checked_roles[$a_role] =
false;
655 $ilLog->write(__METHOD__.
': Assignment allowed.');
656 $checked_roles[$a_role] =
true;
670 if(!$this->__checkSession($sid))
675 global
$ilDB, $tree, $rbacreview, $rbacsystem;
685 switch ($object->getType()) {
695 $roles = $object->__getLocalRoles();
697 foreach($roles as $role_id)
699 $data = array_merge($rbacreview->assignedUsers($role_id),
$data);
705 $member_ids = $object->getGroupMemberIds();
709 $course_ref_id = $tree->checkForParentType(
$ref_id,
'crs');
712 return $this->
__raiseError(
"No course for session",
"Client");
716 include_once
'Modules/Session/classes/class.ilEventParticipants.php';
718 $member_ids = array_keys($event_part->getParticipants());
725 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
728 $xmlWriter->setObjects(
$data);
729 $xmlWriter->setAttachRoles ($attachRoles);
731 if($xmlWriter->start())
733 return $xmlWriter->getXML();
736 return $this->
__raiseError(
'Error in processing information. This is likely a bug.',
'Server');
748 if(!$this->__checkSession($sid))
753 include_once
'./Services/AccessControl/classes/class.ilObjRole.php';
757 $global_roles = $rbacreview->getGlobalRoles();
760 if (in_array($role_id, $global_roles))
762 if ($role_id == SYSTEM_ROLE_ID && ! in_array(SYSTEM_ROLE_ID, $rbacreview->assignedRoles($ilUser->getId()))
765 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
770 $rolf = $rbacreview->getFoldersAssignedToRole($role_id,
true);
771 if ($rbacreview->isDeleted($rolf[0])
772 || ! $rbacsystem->checkAccess(
'write',$rolf[0]))
774 return $this->
__raiseError(
"Role access not permitted. ($role_id)",
"Server");
776 include_once(
'Services/PrivacySecurity/classes/class.ilPrivacySettings.php');
778 if(!$rbacsystem->checkAccess(
'read',SYSTEM_USER_ID)
and 779 !$rbacsystem->checkAccess(
'export_member_data',$privacy->getPrivacySettingsRefId())) {
780 return $this->
__raiseError(
"Export of local role members not permitted. ($role_id)",
"Server");
787 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
790 $xmlWriter->setAttachRoles($attachRoles);
792 $xmlWriter->setObjects(
$data);
794 if($xmlWriter->start())
796 return $xmlWriter->getXML();
798 return $this->
__raiseError(
'Error in getUsersForRole',
'Server');
809 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
810 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
813 $xmlResultSet->addColumn (
"userid");
814 $xmlResultSet->addColumn (
"login");
815 $xmlResultSet->addColumn (
"action");
816 $xmlResultSet->addColumn (
"message");
818 foreach ($a_array as $username =>
$messages)
824 $xmlRow->setValue (0, 0);
825 $xmlRow->setValue (1, $username);
826 $xmlRow->setValue (2,
"");
827 $xmlRow->setValue (3, $message);
829 $xmlResultSet->addRow ($xmlRow);
835 if ($xml_writer->start ())
836 return $xml_writer->getXML();
838 return $this->
__raiseError(
'Error in __getImportProtocolAsXML',
'Server');
849 include_once
'./webservice/soap/classes/class.ilXMLResultSet.php';
850 include_once
'./webservice/soap/classes/class.ilXMLResultSetWriter.php';
853 $xmlResultSet->addColumn (
"userid");
854 $xmlResultSet->addColumn (
"login");
855 $xmlResultSet->addColumn (
"action");
856 $xmlResultSet->addColumn (
"message");
859 foreach ($a_array as $username => $message)
862 $xmlRow->setValue (0, $username);
863 $xmlRow->setValue (1, $message[
"login"]);
864 $xmlRow->setValue (2, $message[
"action"]);
865 $xmlRow->setValue (3, $message[
"message"]);
867 $xmlResultSet->addRow ($xmlRow);
872 if ($xml_writer->start ())
873 return $xml_writer->getXML();
875 return $this->
__raiseError(
'Error in __getUserMappingAsXML',
'Server');
887 function searchUser ($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active) {
892 if(!$this->__checkSession($sid))
897 global
$ilDB, $rbacsystem;
901 return $this->
__raiseError(
'Check access failed.',
'Server');
905 if (!count($a_keyfields))
906 $this->
__raiseError(
'At least one keyfield is needed',
'Client');
908 if (!count ($a_keyvalues))
909 $this->
__raiseError(
'At least one keyvalue is needed',
'Client');
911 if (!strcasecmp($query_operator,
"and")==0 || !strcasecmp($query_operator,
"or") == 0)
912 $this->
__raiseError(
'Query operator must be either \'and\' or \'or\'',
'Client');
917 $query =
"SELECT usr_data.*, usr_pref.value AS language 920 ON usr_pref.usr_id = usr_data.usr_id AND usr_pref.keyword = ".
921 $ilDB->quote(
"language",
"text").
923 WHERE 1 = 1 ".$query;
925 if (is_numeric($active) && $active > -1)
926 $query .=
" AND active = ". $ilDB->quote($active);
928 $query .=
" ORDER BY usr_data.lastname, usr_data.firstname ";
936 while(
$row = $ilDB->fetchAssoc(
$r))
941 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
944 $xmlWriter->setAttachRoles($attach_roles);
946 $xmlWriter->setObjects(
$data);
948 if($xmlWriter->start())
950 return $xmlWriter->getXML();
952 return $this->
__raiseError(
'Error in searchUser',
'Server');
967 $allowed_fields =
array (
"firstname",
"lastname",
"email",
"login",
"matriculation",
"institution",
"department",
"title",
"ext_account");
969 foreach ($a_keyfields as $keyfield)
971 $keyfield = strtolower($keyfield);
973 if (!in_array($keyfield, $allowed_fields))
976 $field_query =
array ();
977 foreach ($a_keyvalues as $keyvalue)
979 if (strlen($keyvalue) >= 3) {
980 $field_query []= $keyfield.
" like '%".$keyvalue.
"%'";
984 if (count($field_query))
985 $query [] = join(
" ".strtoupper($queryOperator).
" ", $field_query);
989 return count (
$query) ?
" AND ((". join(
") OR (",
$query) .
"))" :
"AND 0";
1005 if(!$this->__checkSession($sid))
1014 if(is_array($a_user_ids)
and count($a_user_ids) == 1)
1016 if(end($a_user_ids) == $ilUser->getId())
1021 elseif(is_numeric($a_user_ids))
1023 if($a_user_ids == $ilUser->getId())
1031 return $this->
__raiseError(
'Check access failed.',
'Server');
1038 include_once
'./Services/User/classes/class.ilUserXMLWriter.php';
1040 $xmlWriter->setAttachRoles($attach_roles);
1041 $xmlWriter->setObjects(
$data);
1043 if($xmlWriter->start())
1045 return $xmlWriter->getXML();
1048 return $this->
__raiseError(
'User does not exist',
'Client');
1058 if(!$this->__checkSession($sid))
1065 include_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
1081 if(!$this->__checkSession($sid))
1088 $parts = explode(
'::', $sid);
1089 $query =
"SELECT usr_id FROM usr_session " 1090 .
"INNER JOIN usr_data ON usr_id = user_id WHERE session_id = %s";
1094 if(!(
int)
$data[
'usr_id'])
1099 return (
int)$data[
'usr_id'];
static getUserIdByLogin($a_login)
XML Writer for XMLResultSet.
__buildSearchQuery($a_keyfields, $queryOperator, $a_keyvalues)
create search term according to parameters
checkObjectAccess($ref_id, $expected_type, $permission, $returnObject=false)
check access for ref id: expected type, permission, return object instance if returnobject is true ...
searchUser($sid, $a_keyfields, $query_operator, $a_keyvalues, $attach_roles, $active)
return user xml following dtd 3.7
loginCAS($client, $PT, $username)
const STATUS_AUTHENTICATION_FAILED
Factory for auth frontend classes.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
static _lookupTitle($a_id)
lookup object title
const IL_FAIL_ON_CONFLICT
__initAuthenticationObject($a_auth_mode=AUTH_LOCAL)
getUserXML($sid, $a_user_ids, $attach_roles)
return user xmls for given user ids (csv separated ids) as xml based on usr dtd.
__readUserData(&$usr_obj)
static _getAssignUsersStatus($a_role_id)
isPermittedRole($a_folder, $a_role)
check if assignment is allowed
getUserForRole($sid, $role_id, $attachRoles, $active)
deleteUser($sid, $user_id)
__getImportProtocolAsXML($a_array)
Create XML ResultSet.
loginLDAP($client, $username, $password)
Not required anymode.
loginStudipUser($sid, $user_id)
login as user from Stud.IP
static _lookupObjId($a_id)
__raiseError($a_message, $a_code)
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Create styles array
The data for the language used.
static _getUsersForFolder($ref_id, $active)
get users for a category or from system folder
const STATUS_AUTHENTICATED
static _getUsersForGroup($a_mem_ids, $active=-1)
return user data for group members
logout($sid)
Logout user destroy session.
static setClosingContext($a_context)
set closing context (for statistics)
getUsersForContainer($sid, $ref_id, $attachRoles, $active)
return list of users following dtd users_3_7
static getInstance()
Get status instance.
initAuth($sid)
Init authentication.
importUsers($sid, $folder_id, $usr_xml, $conflict_rule, $send_account_mail)
define ("IL_FAIL_ON_CONFLICT", 1); define ("IL_UPDATE_ON_CONFLICT", 2); define ("IL_IGNORE_ON_CONFLIC...
static _getUsersForIds($a_mem_ids, $active=-1, $timelimitowner=-1)
return user data for given user id
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
const USER_FOLDER_ID
Class ilObjUserFolder.
static getNumberOfNewMailsByUserId($usr_id)
Determines the number of new mails for the passed user id and stores this information in a local cach...
static getLogger($a_component_id)
Get component logger.
domxml_open_mem($str, $mode=0, &$error=NULL)
static _getInstance()
Get instance of ilPrivacySettings.
static _getUsersForRole($role_id, $active=-1)
return array of complete users which belong to a specific role
lookupUser($sid, $user_name)
static __extractId($ilias_id, $inst_id)
extract ref id from role title, e.g.
static _getUserData($a_internalids)
return user data for given user ids
Description of class class.
__getUserMappingAsXML($a_array)
return user mapping as xml
const IL_UPDATE_ON_CONFLICT
const IL_IGNORE_ON_CONFLICT