00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00036 require_once "class.ilObjectGUI.php";
00037
00038 class ilObjAuthSettingsGUI extends ilObjectGUI
00039 {
00044 function ilObjAuthSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
00045 {
00046 $this->type = "auth";
00047 $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
00048
00049 $this->lng->loadLanguageModule('registration');
00050
00051 define('LDAP_DEFAULT_PORT',389);
00052 define('RADIUS_DEFAULT_PORT',1812);
00053 }
00054
00055 function viewObject()
00056 {
00057
00058
00059 include_once './Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
00060
00061
00062 $this->__initSubTabs('');
00063 $this->tabs_gui->setTabActive('settings');
00064 $this->tabs_gui->setSubTabActive('registration_settings');
00065
00066 $registration_gui =& new ilRegistrationSettingsGUI();
00067 $this->ctrl->setCmdClass('ilregistrationsettingsgui');
00068 $this->ctrl->forwardCommand($registration_gui);
00069 }
00070
00071
00077 function authSettingsObject()
00078 {
00079 global $rbacsystem, $ilSetting;
00080
00081 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00082 {
00083 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00084 }
00085
00086 $this->__initSubTabs("authSettings");
00087
00088 $this->getTemplateFile("general");
00089
00090 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00091 $this->tpl->setVariable("TXT_AUTH_TITLE", $this->lng->txt("auth_select"));
00092
00093 $this->tpl->setVariable("TXT_AUTH_MODE", $this->lng->txt("auth_mode"));
00094 $this->tpl->setVariable("TXT_AUTH_DEFAULT", $this->lng->txt("default"));
00095 $this->tpl->setVariable("TXT_AUTH_ACTIVE", $this->lng->txt("active"));
00096 $this->tpl->setVariable("TXT_AUTH_NUM_USERS", $this->lng->txt("num_users"));
00097
00098 $this->tpl->setVariable("TXT_LOCAL", $this->lng->txt("auth_local"));
00099 $this->tpl->setVariable("TXT_LDAP", $this->lng->txt("auth_ldap"));
00100 $this->tpl->setVariable("TXT_SHIB", $this->lng->txt("auth_shib"));
00101
00102 $this->tpl->setVariable("TXT_CAS", $this->lng->txt("auth_cas"));
00103
00104 $this->tpl->setVariable("TXT_RADIUS", $this->lng->txt("auth_radius"));
00105 $this->tpl->setVariable("TXT_SCRIPT", $this->lng->txt("auth_script"));
00106
00107 $auth_cnt = ilObjUser::_getNumberOfUsersPerAuthMode();
00108 $auth_modes = ilAuthUtils::_getAllAuthModes();
00109
00110 foreach($auth_modes as $mode => $mode_name)
00111 {
00112
00113 if ($ilSetting->get('auth_mode') == $mode)
00114 {
00115 $this->tpl->setVariable("NUM_".strtoupper($mode_name),
00116 ((int) $auth_cnt[$mode_name] + $auth_cnt["default"])." (".$this->lng->txt("auth_per_default").
00117 ": ".$auth_cnt["default"].")");
00118 }
00119 else
00120 {
00121 $this->tpl->setVariable("NUM_".strtoupper($mode_name),
00122 (int) $auth_cnt[$mode_name]);
00123 }
00124 }
00125
00126 $this->tpl->setVariable("TXT_CONFIGURE", $this->lng->txt("auth_configure"));
00127 $this->tpl->setVariable("TXT_AUTH_REMARK", $this->lng->txt("auth_remark_non_local_auth"));
00128 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00129 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00130 $this->tpl->setVariable("CMD_SUBMIT", "setAuthMode");
00131
00132
00133 $checked = "checked=\"checked\"";
00134 $disabled = "disabled=\"disabled\"";
00135 $style_disabled = "_disabled";
00136
00137
00138 $icon_ok = "<img src=\"".ilUtil::getImagePath("icon_ok.gif")."\" alt=\"".$this->lng->txt("enabled")."\" title=\"".$this->lng->txt("enabled")."\" border=\"0\" vspace=\"0\"/>";
00139 $icon_not_ok = "<img src=\"".ilUtil::getImagePath("icon_not_ok.gif")."\" alt=\"".$this->lng->txt("disabled")."\" title=\"".$this->lng->txt("disabled")."\" border=\"0\" vspace=\"0\"/>";
00140
00141 $this->tpl->setVariable("AUTH_LOCAL_ACTIVE", $icon_ok);
00142 $this->tpl->setVariable("AUTH_LDAP_ACTIVE", $this->ilias->getSetting('ldap_active') ? $icon_ok : $icon_not_ok);
00143 $this->tpl->setVariable("AUTH_RADIUS_ACTIVE", $this->ilias->getSetting('radius_active') ? $icon_ok : $icon_not_ok);
00144 $this->tpl->setVariable("AUTH_SHIB_ACTIVE", $this->ilias->getSetting('shib_active') ? $icon_ok : $icon_not_ok);
00145 $this->tpl->setVariable("AUTH_SCRIPT_ACTIVE", $this->ilias->getSetting('script_active') ? $icon_ok : $icon_not_ok);
00146 $this->tpl->setVariable("AUTH_CAS_ACTIVE", $this->ilias->getSetting('cas_active') ? $icon_ok : $icon_not_ok);
00147
00148
00149 switch ($this->ilias->getSetting('auth_mode'))
00150 {
00151 case AUTH_LOCAL:
00152 $this->tpl->setVariable("CHK_LOCAL", $checked);
00153 break;
00154
00155 case AUTH_LDAP:
00156 $this->tpl->setVariable("CHK_LDAP", $checked);
00157 break;
00158
00159 case AUTH_SHIBBOLETH:
00160 $this->tpl->setVariable("CHK_SHIB", $checked);
00161 break;
00162
00163 case AUTH_RADIUS:
00164 $this->tpl->setVariable("CHK_RADIUS", $checked);
00165 break;
00166
00167 case AUTH_CAS:
00168 $this->tpl->setVariable("CHK_CAS", $checked);
00169 break;
00170
00171 case AUTH_SCRIPT:
00172 $this->tpl->setVariable("CHK_SCRIPT", $checked);
00173 break;
00174 }
00175
00176
00177
00178 $this->tpl->setVariable("FORMACTION_ROLES",
00179 $this->ctrl->getFormAction($this));
00180 $this->tpl->setVariable("TXT_AUTH_ROLES", $this->lng->txt("auth_active_roles"));
00181 $this->tpl->setVariable("TXT_ROLE", $this->lng->txt("obj_role"));
00182 $this->tpl->setVariable("TXT_ROLE_AUTH_MODE", $this->lng->txt("auth_role_auth_mode"));
00183 $this->tpl->setVariable("CMD_SUBMIT_ROLES", "updateAuthRoles");
00184
00185 include_once("classes/class.ilObjRole.php");
00186 $reg_roles = ilObjRole::_lookupRegisterAllowed();
00187
00188
00189 include_once('classes/class.ilAuthUtils.php');
00190 $active_auth_modes = ilAuthUtils::_getActiveAuthModes();
00191
00192 foreach ($reg_roles as $role)
00193 {
00194 foreach ($active_auth_modes as $auth_name => $auth_key)
00195 {
00196
00197
00198
00199 if ($auth_name == "default" || $auth_name == "cas"
00200 || $auth_name == "shibboleth")
00201 {
00202 continue;
00203 }
00204
00205 $this->tpl->setCurrentBlock("auth_mode_selection");
00206
00207 if ($auth_name == 'default')
00208 {
00209 $name = $this->lng->txt('auth_'.$auth_name)." (".$this->lng->txt('auth_'.ilAuthUtils::_getAuthModeName($auth_key)).")";
00210 }
00211 else
00212 {
00213 $name = $this->lng->txt('auth_'.$auth_name);
00214 }
00215
00216 $this->tpl->setVariable("AUTH_MODE_NAME", $name);
00217
00218 $this->tpl->setVariable("AUTH_MODE", $auth_name);
00219
00220 if ($role['auth_mode'] == $auth_name)
00221 {
00222 $this->tpl->setVariable("SELECTED_AUTH_MODE", "selected=\"selected\"");
00223 }
00224
00225 $this->tpl->parseCurrentBlock();
00226 }
00227
00228 $this->tpl->setCurrentBlock("roles");
00229 $this->tpl->setVariable("ROLE", $role['title']);
00230 $this->tpl->setVariable("ROLE_ID", $role['id']);
00231 $this->tpl->parseCurrentBlock();
00232 }
00233 }
00234
00235 function cancelObject()
00236 {
00237 sendInfo($this->lng->txt("msg_cancel"),true);
00238 $this->ctrl->redirect($this, "authSettings");
00239 }
00240
00241 function getAdminTabs(&$tabs_gui)
00242 {
00243 $this->getTabs($tabs_gui);
00244 }
00245
00251 function getTabs(&$tabs_gui)
00252 {
00253 global $rbacsystem;
00254
00255 $this->ctrl->setParameter($this,"ref_id",$this->object->getRefId());
00256
00257 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00258 {
00259 $tabs_gui->addTarget("settings",
00260 $this->ctrl->getLinkTarget($this, "view"), array("authSettings","editRADIUS","editLDAP","editSHIB","editCAS","editSOAP",""), "", "");
00261 }
00262
00263 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00264 {
00265 $tabs_gui->addTarget("perm_settings",
00266 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
00267 }
00268 }
00269
00270 function setAuthModeObject()
00271 {
00272 global $rbacsystem;
00273
00274 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
00275 {
00276 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00277 }
00278
00279 if (empty($_POST["auth_mode"]))
00280 {
00281 $this->ilias->raiseError($this->lng->txt("auth_err_no_mode_selected"),$this->ilias->error_obj->MESSAGE);
00282 }
00283
00284 if ($_POST["auth_mode"] == AUTH_DEFAULT)
00285 {
00286 sendInfo($this->lng->txt("auth_mode").": ".$this->getAuthModeTitle()." ".$this->lng->txt("auth_mode_not_changed"),true);
00287 $this->ctrl->redirect($this,'authSettings');
00288 }
00289
00290 switch ($_POST["auth_mode"])
00291 {
00292 case AUTH_LDAP:
00293 if ($this->object->checkAuthLDAP() !== true)
00294 {
00295 sendInfo($this->lng->txt("auth_ldap_not_configured"),true);
00296 ilUtil::redirect($this->getReturnLocation("authSettings",$this->ctrl->getLinkTarget($this,"editLDAP")));
00297 }
00298 break;
00299
00300 case AUTH_SHIB:
00301 if ($this->object->checkAuthSHIB() !== true)
00302 {
00303 sendInfo($this->lng->txt("auth_shib_not_configured"),true);
00304 ilUtil::redirect($this->getReturnLocation("authSettings",$this->ctrl->getLinkTarget($this,"editSHIB")));
00305 }
00306 break;
00307
00308 case AUTH_RADIUS:
00309 if ($this->object->checkAuthRADIUS() !== true)
00310 {
00311 sendInfo($this->lng->txt("auth_radius_not_configured"),true);
00312 $this->ctrl->redirect($this,'editRADIUS');
00313 }
00314 break;
00315
00316 case AUTH_SCRIPT:
00317 if ($this->object->checkAuthScript() !== true)
00318 {
00319 sendInfo($this->lng->txt("auth_script_not_configured"),true);
00320 ilUtil::redirect($this->getReturnLocation("authSettings",$this->ctrl->getLinkTarget($this,"editScript")));
00321 }
00322 break;
00323 }
00324
00325 $this->ilias->setSetting("auth_mode",$_POST["auth_mode"]);
00326
00327 sendInfo($this->lng->txt("auth_default_mode_changed_to")." ".$this->getAuthModeTitle(),true);
00328 $this->ctrl->redirect($this,'authSettings');
00329 }
00330
00336 function editLDAPObject()
00337 {
00338 global $rbacsystem;
00339
00340 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
00341 {
00342 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00343 }
00344
00345 $this->__initSubTabs("editLDAP");
00346
00347 if ($_SESSION["error_post_vars"])
00348 {
00349 if ($_SESSION["error_post_vars"]["ldap"]["active"] == "1")
00350 {
00351 $this->tpl->setVariable("CHK_LDAP_ACTIVE", "checked=\"checked\"");
00352 }
00353
00354 if ($_SESSION["error_post_vars"]["ldap"]["tls"] == "1")
00355 {
00356 $this->tpl->setVariable("LDAP_TLS_CHK", "checked=\"checked\"");
00357 }
00358
00359 if ($_SESSION["error_post_vars"]["ldap"]["version"] == "3")
00360 {
00361 $this->tpl->setVariable("LDAP_VERSION3_CHK", "checked=\"checked\"");
00362 }
00363 else
00364 {
00365 $this->tpl->setVariable("LDAP_VERSION2_CHK", "checked=\"checked\"");
00366 }
00367
00368 $this->tpl->setVariable("LDAP_SERVER", $_SESSION["error_post_vars"]["ldap"]["server"]);
00369 $this->tpl->setVariable("LDAP_BASEDN", $_SESSION["error_post_vars"]["ldap"]["basedn"]);
00370 $this->tpl->setVariable("LDAP_SEARCH_BASE", $_SESSION["error_post_vars"]["ldap"]["search_base"]);
00371 $this->tpl->setVariable("LDAP_PORT", $_SESSION["error_post_vars"]["ldap"]["port"]);
00372 $this->tpl->setVariable("LDAP_LOGIN_KEY", $_SESSION["error_post_vars"]["ldap"]["login_key"]);
00373 $this->tpl->setVariable("LDAP_OBJECTCLASS", $_SESSION["error_post_vars"]["ldap"]["objectclass"]);
00374 }
00375 else
00376 {
00377
00378 $settings = $this->ilias->getAllSettings();
00379
00380 if ($settings["ldap_active"] == "1")
00381 {
00382 $this->tpl->setVariable("CHK_LDAP_ACTIVE", "checked=\"checked\"");
00383 }
00384
00385 if ($settings["ldap_tls"] == "1")
00386 {
00387 $this->tpl->setVariable("LDAP_TLS_CHK", "checked=\"checked\"");
00388 }
00389
00390 $this->tpl->setVariable("LDAP_SERVER", $settings["ldap_server"]);
00391 $this->tpl->setVariable("LDAP_BASEDN", $settings["ldap_basedn"]);
00392 $this->tpl->setVariable("LDAP_SEARCH_BASE", $settings["ldap_search_base"]);
00393
00394 if (empty($settings["ldap_port"]))
00395 {
00396 $this->tpl->setVariable("LDAP_PORT", LDAP_DEFAULT_PORT);
00397 }
00398 else
00399 {
00400 $this->tpl->setVariable("LDAP_PORT", $settings["ldap_port"]);
00401 }
00402
00403 if (empty($settings["ldap_login_key"]))
00404 {
00405 $this->tpl->setVariable("LDAP_LOGIN_KEY", "uid");
00406 }
00407 else
00408 {
00409 $this->tpl->setVariable("LDAP_LOGIN_KEY", $settings["ldap_login_key"]);
00410 }
00411
00412 if (empty($settings["ldap_objectclass"]))
00413 {
00414 $this->tpl->setVariable("LDAP_OBJECTCLASS", "posixAccount");
00415 }
00416 else
00417 {
00418 $this->tpl->setVariable("LDAP_OBJECTCLASS", $settings["ldap_objectclass"]);
00419 }
00420
00421 if (empty($settings["ldap_version"]) or $settings["ldap_version"] == "2")
00422 {
00423 $this->tpl->setVariable("LDAP_VERSION2_CHK", "checked=\"checked\"");
00424 }
00425 else
00426 {
00427 $this->tpl->setVariable("LDAP_VERSION3_CHK", "checked=\"checked\"");
00428 }
00429 }
00430
00431 $this->getTemplateFile("ldap");
00432
00433 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00434 $this->tpl->setVariable("COLSPAN", 3);
00435 $this->tpl->setVariable("TXT_LDAP_TITLE", $this->lng->txt("ldap_configure"));
00436 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
00437 $this->tpl->setVariable("TXT_LDAP_ACTIVE", $this->lng->txt("auth_ldap_enable"));
00438 $this->tpl->setVariable("TXT_LDAP_TLS", $this->lng->txt("ldap_tls"));
00439 $this->tpl->setVariable("TXT_LDAP_SERVER", $this->lng->txt("ldap_server"));
00440 $this->tpl->setVariable("TXT_LDAP_BASEDN", $this->lng->txt("ldap_basedn"));
00441 $this->tpl->setVariable("TXT_LDAP_SEARCH_BASE", $this->lng->txt("ldap_search_base"));
00442 $this->tpl->setVariable("TXT_LDAP_PORT", $this->lng->txt("ldap_port"));
00443 $this->tpl->setVariable("TXT_LDAP_TLS", $this->lng->txt("ldap_tls"));
00444
00445 $this->tpl->setVariable("TXT_LDAP_VERSION", $this->lng->txt("ldap_version"));
00446 $this->tpl->setVariable("TXT_LDAP_VERSION2", $this->lng->txt("ldap_v2"));
00447 $this->tpl->setVariable("TXT_LDAP_VERSION3", $this->lng->txt("ldap_v3"));
00448
00449 $this->tpl->setVariable("TXT_LDAP_LOGIN_KEY", $this->lng->txt("ldap_login_key"));
00450 $this->tpl->setVariable("TXT_LDAP_OBJECTCLASS", $this->lng->txt("ldap_objectclass"));
00451
00452 $this->tpl->setVariable("TXT_LDAP_PASSWD", $this->lng->txt("ldap_passwd"));
00453
00454 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00455 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00456 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00457 $this->tpl->setVariable("CMD_SUBMIT", "saveLDAP");
00458 }
00459
00460
00466 function saveLDAPObject()
00467 {
00468 global $ilUser;
00469
00470
00471 if (!$_POST["ldap"]["server"] or !$_POST["ldap"]["basedn"] or !$_POST["ldap"]["port"] or !$_POST["ldap"]["login_key"] or !$_POST["ldap"]["objectclass"])
00472 {
00473 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00474 }
00475
00476
00477 if (!$_POST["ldap"]["passwd"])
00478 {
00479 $this->ilias->raiseError($this->lng->txt("err_enter_current_passwd"),$this->ilias->error_obj->MESSAGE);
00480 }
00481
00482
00483 if ((preg_match("/^[0-9]{0,5}$/",$_POST["ldap"]["port"])) == false)
00484 {
00485 $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
00486 }
00487
00488
00489 if ($_POST["ldap"]["tls"] != "1")
00490 {
00491 $_POST["ldap"]["tls"] = "0";
00492 }
00493
00494
00495
00496
00497 $ldap_host = $_POST["ldap"]["server"];
00498 $ldap_port = $_POST["ldap"]["port"];
00499 $ldap_pass = $_POST["ldap"]["passwd"];
00500
00501 $ldap_userattr = $_POST["ldap"]["login_key"];
00502 $ldap_useroc = $_POST["ldap"]["objectclass"];
00503
00504 $ldap_dn = $ldap_userattr."=".$this->ilias->account->getLogin().",";
00505
00506
00507 if ($_POST["ldap"]["search_base"])
00508 {
00509 $ldap_searchbase .= $_POST["ldap"]["search_base"].",";
00510 }
00511
00512 $ldap_searchbase .= $_POST["ldap"]["basedn"];
00513
00514 $ldap_dn .= $ldap_searchbase;
00515
00516
00517 $ldap_conn = ldap_connect($ldap_host,$ldap_port);
00518
00519 @ldap_set_option($ldap_conn, LDAP_OPT_PROTOCOL_VERSION, $_POST["ldap"]["version"]);
00520
00521
00522 if (($ldap_bind = ldap_bind($ldap_conn)) == false)
00523 {
00524 $this->ilias->raiseError($this->lng->txt("err_ldap_connect_failed"),$this->ilias->error_obj->MESSAGE);
00525 }
00526
00527
00528 $filter = sprintf('(&(objectClass=%s)(%s=%s))', $ldap_useroc, $ldap_userattr, $ilUser->getLogin());
00529
00530
00531 $func_params = array($ldap_conn, $ldap_searchbase, $filter, array($ldap_userattr));
00532
00533
00534 if (($result_id = @call_user_func_array('ldap_search', $func_params)) == false)
00535 {
00536 $this->ilias->raiseError($this->lng->txt("err_ldap_search_failed"),$this->ilias->error_obj->MESSAGE);
00537 }
00538
00539 if (ldap_count_entries($ldap_conn, $result_id) != 1)
00540 {
00541 $this->ilias->raiseError($this->lng->txt("err_ldap_user_not_found"),$this->ilias->error_obj->MESSAGE);
00542 }
00543
00544
00545 $entry_id = ldap_first_entry($ldap_conn, $result_id);
00546 $user_dn = ldap_get_dn($ldap_conn, $entry_id);
00547
00548 ldap_free_result($result_id);
00549
00550
00551 if (@ldap_bind($ldap_conn, $user_dn, $ldap_pass) == false)
00552 {
00553 $this->ilias->raiseError($this->lng->txt("err_ldap_auth_failed"),$this->ilias->error_obj->MESSAGE);
00554 }
00555
00556
00557 @ldap_unbind($ldap_conn);
00558
00559
00560 $this->ilias->setSetting("ldap_tls", $_POST["ldap"]["tls"]);
00561 $this->ilias->setSetting("ldap_server", $_POST["ldap"]["server"]);
00562 $this->ilias->setSetting("ldap_basedn", $_POST["ldap"]["basedn"]);
00563 $this->ilias->setSetting("ldap_search_base", $_POST["ldap"]["search_base"]);
00564 $this->ilias->setSetting("ldap_port", $_POST["ldap"]["port"]);
00565 $this->ilias->setSetting("ldap_version", $_POST["ldap"]["version"]);
00566 $this->ilias->setSetting("ldap_login_key", $_POST["ldap"]["login_key"]);
00567 $this->ilias->setSetting("ldap_objectclass", $_POST["ldap"]["objectclass"]);
00568 $this->ilias->setSetting("ldap_active", $_POST["ldap"]["active"]);
00569
00570 sendInfo($this->lng->txt("auth_ldap_settings_saved"),true);
00571 $this->ctrl->redirect($this,'editLDAP');;
00572 }
00573
00579 function editSHIBObject()
00580 {
00581 global $rbacsystem, $rbacreview;
00582
00583 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
00584 {
00585 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00586 }
00587
00588 $this->__initSubTabs("editSHIB");
00589
00590
00591 $settings = $this->ilias->getAllSettings();
00592
00593
00594 $role_list = $rbacreview->getRolesByFilter(2,$this->object->getId());
00595 $selectElement = '<select name="shib[user_default_role]">';
00596
00597 if (!isset($settings["shib_user_default_role"]))
00598 {
00599 $settings["shib_user_default_role"] = 4;
00600 }
00601
00602 foreach ($role_list as $role)
00603 {
00604 $selectElement .= '<option value="'.$role['obj_id'].'"';
00605 if ($settings["shib_user_default_role"] == $role['obj_id'])
00606 $selectElement .= 'selected="selected"';
00607
00608 $selectElement .= '>'.$role['title'].'</option>';
00609 }
00610 $selectElement .= '</select>';
00611
00612
00613
00614 $shib_settings = array(
00615 'shib_login',
00616 'shib_title',
00617 'shib_firstname',
00618 'shib_lastname',
00619 'shib_email',
00620 'shib_gender',
00621 'shib_institution',
00622 'shib_department',
00623 'shib_zipcode',
00624 'shib_city',
00625 'shib_country',
00626 'shib_street',
00627 'shib_phone_office',
00628 'shib_phone_home',
00629 'shib_phone_mobile',
00630 'shib_language'
00631 );
00632
00633 $this->getTemplateFile("shib");
00634
00635 foreach ($shib_settings as $setting)
00636 {
00637 $field = ereg_replace('shib_','',$setting);
00638 $this->tpl->setVariable(strtoupper($setting), $settings[$setting]);
00639 $this->tpl->setVariable('SHIB_UPDATE_'.strtoupper($field), $settings["shib_update_".$field]);
00640
00641 if ($settings["shib_update_".$field])
00642 $this->tpl->setVariable('CHK_SHIB_UPDATE_'.strtoupper($field), 'checked="checked"');
00643 }
00644
00645
00646
00647 if (!isset($settings["shib_login_button"]) || $settings["shib_login_button"] == ''){
00648 $this->tpl->setVariable("SHIB_LOGIN_BUTTON", "images/shib_login_button.gif");
00649 }
00650
00651 if (isset($settings["shib_active"]) && $settings["shib_active"])
00652 {
00653 $this->tpl->setVariable("chk_shib_active", 'checked="checked"');
00654 }
00655
00656 if (
00657 !isset($settings["shib_hos_type"])
00658 || $settings["shib_hos_type"] == ''
00659 || $settings["shib_hos_type"] != 'external_wayf'
00660 )
00661 {
00662 $this->tpl->setVariable("CHK_SHIB_LOGIN_INTERNAL_WAYF", 'checked="checked"');
00663 $this->tpl->setVariable("CHK_SHIB_LOGIN_EXTERNAL_WAYF", '');
00664 } else {
00665 $this->tpl->setVariable("CHK_SHIB_LOGIN_INTERNAL_WAYF", '');
00666 $this->tpl->setVariable("CHK_SHIB_LOGIN_EXTERNAL_WAYF", 'checked="checked"');
00667 }
00668
00669 if (!isset($settings["shib_idp_list"]) || $settings["shib_idp_list"] == '')
00670 {
00671 $this->tpl->setVariable("SHIB_IDP_LIST", "urn:mace:organization1:providerID, Example Organization 1\nurn:mace:organization2:providerID, Example Organization 2, /Shibboleth.sso/WAYF/SWITCHaai");
00672 } else {
00673 $this->tpl->setVariable("SHIB_IDP_LIST", stripslashes($settings["shib_idp_list"]));
00674 }
00675
00676 $this->tpl->setVariable("SHIB_USER_DEFAULT_ROLE", $selectElement);
00677 $this->tpl->setVariable("SHIB_LOGIN_BUTTON", $settings["shib_login_button"]);
00678 $this->tpl->setVariable("SHIB_LOGIN_INSTRUCTIONS", stripslashes($settings["shib_login_instructions"]));
00679 $this->tpl->setVariable("SHIB_FEDERATION_NAME", stripslashes($settings["shib_federation_name"]));
00680 $this->tpl->setVariable("SHIB_DATA_CONV", $settings["shib_data_conv"]);
00681
00682 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00683 $this->tpl->setVariable("COLSPAN", 3);
00684 $this->tpl->setVariable("TXT_SHIB_INSTRUCTIONS", $this->lng->txt("shib_instructions"));
00685 $this->tpl->setVariable("TXT_SHIB", $this->lng->txt("shib"));
00686 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
00687 $this->tpl->setVariable("TXT_SHIB_UPDATE", $this->lng->txt("shib_update"));
00688 $this->tpl->setVariable("TXT_SHIB_ACTIVE", $this->lng->txt("shib_active"));
00689 $this->tpl->setVariable("TXT_SHIB_USER_DEFAULT_ROLE", $this->lng->txt("shib_user_default_role"));
00690 $this->tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $this->lng->txt("shib_login_button"));
00691 $this->tpl->setVariable("TXT_SHIB_LOGIN_TYPE", $this->lng->txt("shib_login_type"));
00692 $this->tpl->setVariable("TXT_SHIB_LOGIN_INTERNAL_WAYF", $this->lng->txt("shib_login_internal_wayf"));
00693 $this->tpl->setVariable("TXT_SHIB_LOGIN_EXTERNAL_WAYF", $this->lng->txt("shib_login_external_wayf"));
00694 $this->tpl->setVariable("TXT_SHIB_IDP_LIST", $this->lng->txt("shib_idp_list"));
00695 $this->tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $this->lng->txt("shib_federation_name"));
00696 $this->tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", $this->lng->txt("auth_login_instructions"));
00697 $this->tpl->setVariable("TXT_SHIB_DATA_CONV", $this->lng->txt("shib_data_conv"));
00698 foreach ($shib_settings as $setting)
00699 {
00700 $this->tpl->setVariable("TXT_".strtoupper($setting), $this->lng->txt($setting));
00701 }
00702
00703 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00704 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00705 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00706 $this->tpl->setVariable("CMD_SUBMIT", "saveSHIB");
00707
00708 }
00709
00715 function saveSHIBObject()
00716 {
00717 global $ilUser;
00718
00719
00720 if (
00721 !$_POST["shib"]["login"]
00722 or !$_POST["shib"]["hos_type"]
00723 or !$_POST["shib"]["firstname"]
00724 or !$_POST["shib"]["lastname"]
00725 or !$_POST["shib"]["email"]
00726 or !$_POST["shib"]["user_default_role"]
00727 or !$_POST["shib"]["federation_name"]
00728 )
00729 {
00730 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00731 }
00732
00733
00734 if (
00735 $_POST["shib"]["data_conv"]
00736 and $_POST["shib"]["data_conv"] != ''
00737 and !is_readable($_POST["shib"]["data_conv"]) )
00738 {
00739 $this->ilias->raiseError($this->lng->txt("shib_data_conv_warning"),$this->ilias->error_obj->MESSAGE);
00740 }
00741
00742
00743 $shib_settings = array(
00744 'shib_login',
00745 'shib_title',
00746 'shib_firstname',
00747 'shib_lastname',
00748 'shib_email',
00749 'shib_gender',
00750 'shib_institution',
00751 'shib_department',
00752 'shib_zipcode',
00753 'shib_city',
00754 'shib_country',
00755 'shib_street',
00756 'shib_phone_office',
00757 'shib_phone_home',
00758 'shib_phone_mobile',
00759 'shib_language'
00760 );
00761
00762 foreach ($shib_settings as $setting)
00763 {
00764 $field = ereg_replace('shib_','',$setting);
00765 if ($_POST["shib"]["update_".$field] != "1")
00766 $_POST["shib"]["update_".$field] = "0";
00767 $this->ilias->setSetting($setting, trim($_POST["shib"][$field]));
00768 $this->ilias->setSetting("shib_update_".$field, $_POST["shib"]["update_".$field]);
00769 }
00770
00771 if ($_POST["shib"]["active"] != "1")
00772 {
00773 $this->ilias->setSetting("shib_active", "0");
00774 }
00775 else
00776 {
00777 $this->ilias->setSetting("shib_active", "1");
00778 }
00779
00780 $this->ilias->setSetting("shib_user_default_role", $_POST["shib"]["user_default_role"]);
00781 $this->ilias->setSetting("shib_hos_type", $_POST["shib"]["hos_type"]);
00782 $this->ilias->setSetting("shib_federation_name", $_POST["shib"]["federation_name"]);
00783 $this->ilias->setSetting("shib_idp_list", $_POST["shib"]["idp_list"]);
00784 $this->ilias->setSetting("shib_login_instructions", $_POST["shib"]["login_instructions"]);
00785 $this->ilias->setSetting("shib_login_button", $_POST["shib"]["login_button"]);
00786 $this->ilias->setSetting("shib_data_conv", $_POST["shib"]["data_conv"]);
00787
00788 sendInfo($this->lng->txt("shib_settings_saved"),true);
00789
00790 $this->ctrl->redirect($this,'editSHIB');
00791 }
00792
00798 function editCASObject()
00799 {
00800 global $rbacsystem, $rbacreview, $ilSetting;
00801
00802 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
00803 {
00804 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00805 }
00806
00807 $this->__initSubTabs("editCAS");
00808
00809
00810 $this->getTemplateFile("cas");
00811
00812
00813 $settings = $ilSetting->getAll();
00814
00815
00816 if ($_SESSION["error_post_vars"])
00817 {
00818 if ($_SESSION["error_post_vars"]["cas"]["active"] == "1")
00819 {
00820 $this->tpl->setVariable("CHK_CAS_ACTIVE", "checked=\"checked\"");
00821 }
00822 if ($_SESSION["error_post_vars"]["cas"]["create_users"] == "1")
00823 {
00824 $this->tpl->setVariable("CHK_CREATE_USERS", "checked=\"checked\"");
00825 }
00826 if ($_SESSION["error_post_vars"]["cas"]["allow_local"] == "1")
00827 {
00828 $this->tpl->setVariable("CHK_ALLOW_LOCAL", "checked=\"checked\"");
00829 }
00830
00831 $this->tpl->setVariable("CAS_SERVER", $_SESSION["error_post_vars"]["cas"]["server"]);
00832 $this->tpl->setVariable("CAS_PORT", $_SESSION["error_post_vars"]["cas"]["port"]);
00833 $this->tpl->setVariable("CAS_URI", $_SESSION["error_post_vars"]["cas"]["uri"]);
00834 $this->tpl->setVariable("CAS_LOGIN_INSTRUCTIONS", $_SESSION["error_post_vars"]["cas"]["login_instructions"]);
00835 $current_default_role = $_SESSION["error_post_vars"]["cas"]["user_default_role"];
00836 }
00837 else
00838 {
00839 if ($settings["cas_active"] == "1")
00840 {
00841 $this->tpl->setVariable("CHK_CAS_ACTIVE", "checked=\"checked\"");
00842 }
00843 if ($settings["cas_create_users"] == "1")
00844 {
00845 $this->tpl->setVariable("CHK_CREATE_USERS", "checked=\"checked\"");
00846 }
00847 if ($settings["cas_allow_local"] == "1")
00848 {
00849 $this->tpl->setVariable("CHK_ALLOW_LOCAL", "checked=\"checked\"");
00850 }
00851
00852 $this->tpl->setVariable("CAS_SERVER", $settings["cas_server"]);
00853 $this->tpl->setVariable("CAS_PORT", $settings["cas_port"]);
00854 $this->tpl->setVariable("CAS_URI", $settings["cas_uri"]);
00855 $this->tpl->setVariable("CAS_LOGIN_INSTRUCTIONS", $settings["cas_login_instructions"]);
00856 $current_default_role = $settings["cas_user_default_role"];
00857 }
00858
00859
00860 $role_list = $rbacreview->getRolesByFilter(2,$this->object->getId());
00861 if (!$current_default_role)
00862 {
00863 $current_default_role = 4;
00864 }
00865 $roles = array();
00866 foreach ($role_list as $role)
00867 {
00868 $roles[$role['obj_id']] = $role['title'];
00869 }
00870 $selectElement = ilUtil::formSelect($current_default_role,
00871 "cas[user_default_role]", $roles, false, true);
00872
00873 $this->tpl->setVariable("CAS_USER_DEFAULT_ROLE", $selectElement);
00874 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
00875 $this->tpl->setVariable("COLSPAN", 3);
00876 $this->tpl->setVariable("TXT_CAS_TITLE", $this->lng->txt("auth_cas_auth"));
00877 $this->tpl->setVariable("TXT_CAS_DESC", $this->lng->txt("auth_cas_auth_desc"));
00878 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
00879 $this->tpl->setVariable("TXT_CAS_ACTIVE", $this->lng->txt("active"));
00880 $this->tpl->setVariable("TXT_CAS_SERVER", $this->lng->txt("server"));
00881 $this->tpl->setVariable("TXT_CAS_SERVER_DESC", $this->lng->txt("auth_cas_server_desc"));
00882 $this->tpl->setVariable("TXT_CAS_PORT", $this->lng->txt("port"));
00883 $this->tpl->setVariable("TXT_CAS_PORT_DESC", $this->lng->txt("auth_cas_port_desc"));
00884 $this->tpl->setVariable("TXT_CAS_URI", $this->lng->txt("uri"));
00885 $this->tpl->setVariable("TXT_CAS_URI_DESC", $this->lng->txt("auth_cas_uri_desc"));
00886 $this->tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $this->lng->txt("auth_login_instructions"));
00887 $this->tpl->setVariable("TXT_CREATE_USERS", $this->lng->txt("auth_create_users"));
00888 $this->tpl->setVariable("TXT_CREATE_USERS_DESC", $this->lng->txt("auth_cas_create_users_desc"));
00889 $this->tpl->setVariable("TXT_CAS_USER_DEFAULT_ROLE", $this->lng->txt("auth_user_default_role"));
00890 $this->tpl->setVariable("TXT_CAS_USER_DEFAULT_ROLE_DESC",
00891 $this->lng->txt("auth_cas_user_default_role_desc"));
00892 $this->tpl->setVariable("TXT_ALLOW_LOCAL", $this->lng->txt("auth_allow_local"));
00893 $this->tpl->setVariable("TXT_ALLOW_LOCAL_DESC", $this->lng->txt("auth_cas_allow_local_desc"));
00894 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00895 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
00896 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
00897 $this->tpl->setVariable("CMD_SUBMIT", "saveCAS");
00898 }
00899
00905 function saveCASObject()
00906 {
00907 global $ilUser, $ilSetting;
00908
00909
00910 if (!$_POST["cas"]["server"] or !$_POST["cas"]["port"])
00911 {
00912 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
00913 }
00914
00915
00916 if ((preg_match("/^[0-9]{0,5}$/",$_POST["cas"]["port"])) == false)
00917 {
00918 $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
00919 }
00920
00921 $ilSetting->set("cas_server", $_POST["cas"]["server"]);
00922 $ilSetting->set("cas_port", $_POST["cas"]["port"]);
00923 $ilSetting->set("cas_uri", $_POST["cas"]["uri"]);
00924 $ilSetting->set("cas_login_instructions", $_POST["cas"]["login_instructions"]);
00925 $ilSetting->set("cas_active", $_POST["cas"]["active"]);
00926 $ilSetting->set("cas_create_users", $_POST["cas"]["create_users"]);
00927 $ilSetting->set("cas_allow_local", $_POST["cas"]["allow_local"]);
00928 $ilSetting->set("cas_active", $_POST["cas"]["active"]);
00929 $ilSetting->set("cas_user_default_role", $_POST["cas"]["user_default_role"]);
00930 sendInfo($this->lng->txt("auth_cas_settings_saved"),true);
00931
00932 $this->ctrl->redirect($this,'editCAS');
00933 }
00934
00940 function editSOAPObject()
00941 {
00942 global $rbacsystem, $rbacreview, $ilSetting;
00943
00944 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
00945 {
00946 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
00947 }
00948
00949 $this->__initSubTabs("editSOAP");
00950
00951
00952 $this->getTemplateFile("soap");
00953
00954
00955 $settings = $ilSetting->getAll();
00956
00957
00958 if ($_SESSION["error_post_vars"])
00959 {
00960 if ($_SESSION["error_post_vars"]["soap"]["active"] == "1")
00961 {
00962 $this->tpl->setVariable("CHK_SOAP_ACTIVE", "checked=\"checked\"");
00963 }
00964 if ($_SESSION["error_post_vars"]["soap"]["use_https"] == "1")
00965 {
00966 $this->tpl->setVariable("CHK_USE_HTTPS", "checked=\"checked\"");
00967 }
00968 if ($_SESSION["error_post_vars"]["soap"]["create_users"] == "1")
00969 {
00970 $this->tpl->setVariable("CHK_CREATE_USERS", "checked=\"checked\"");
00971 }
00972 if ($_SESSION["error_post_vars"]["soap"]["allow_local"] == "1")
00973 {
00974 $this->tpl->setVariable("CHK_ALLOW_LOCAL", "checked=\"checked\"");
00975 }
00976 if ($_SESSION["error_post_vars"]["soap"]["account_mail"] == "1")
00977 {
00978 $this->tpl->setVariable("CHK_ACCOUNT_MAIL", "checked=\"checked\"");
00979 }
00980 if ($_SESSION["error_post_vars"]["soap"]["use_dotnet"] == "1")
00981 {
00982 $this->tpl->setVariable("CHK_USEDOTNET", "checked=\"checked\"");
00983 }
00984
00985 $this->tpl->setVariable("SOAP_SERVER", $_SESSION["error_post_vars"]["soap"]["server"]);
00986 $this->tpl->setVariable("SOAP_PORT", $_SESSION["error_post_vars"]["soap"]["port"]);
00987 $this->tpl->setVariable("SOAP_URI", $_SESSION["error_post_vars"]["soap"]["uri"]);
00988 $this->tpl->setVariable("SOAP_NAMESPACE", $_SESSION["error_post_vars"]["soap"]["namespace"]);
00989 $current_default_role = $_SESSION["error_post_vars"]["soap"]["user_default_role"];
00990 }
00991 else
00992 {
00993 if ($settings["soap_auth_active"] == "1")
00994 {
00995 $this->tpl->setVariable("CHK_SOAP_ACTIVE", "checked=\"checked\"");
00996 }
00997 if ($settings["soap_auth_use_https"] == "1")
00998 {
00999 $this->tpl->setVariable("CHK_USE_HTTPS", "checked=\"checked\"");
01000 }
01001 if ($settings["soap_auth_create_users"] == "1")
01002 {
01003 $this->tpl->setVariable("CHK_CREATE_USERS", "checked=\"checked\"");
01004 }
01005 if ($settings["soap_auth_allow_local"] == "1")
01006 {
01007 $this->tpl->setVariable("CHK_ALLOW_LOCAL", "checked=\"checked\"");
01008 }
01009 if ($settings["soap_auth_account_mail"] == "1")
01010 {
01011 $this->tpl->setVariable("CHK_ACCOUNT_MAIL", "checked=\"checked\"");
01012 }
01013 if ($settings["soap_auth_use_dotnet"] == "1")
01014 {
01015 $this->tpl->setVariable("CHK_USE_DOTNET", "checked=\"checked\"");
01016 }
01017
01018 $this->tpl->setVariable("SOAP_SERVER", $settings["soap_auth_server"]);
01019 $this->tpl->setVariable("SOAP_PORT", $settings["soap_auth_port"]);
01020 $this->tpl->setVariable("SOAP_URI", $settings["soap_auth_uri"]);
01021 $this->tpl->setVariable("SOAP_NAMESPACE", $settings["soap_auth_namespace"]);
01022 $current_default_role = $settings["soap_auth_user_default_role"];
01023 }
01024
01025
01026 $role_list = $rbacreview->getRolesByFilter(2,$this->object->getId());
01027 if (!$current_default_role)
01028 {
01029 $current_default_role = 4;
01030 }
01031 $roles = array();
01032 foreach ($role_list as $role)
01033 {
01034 $roles[$role['obj_id']] = $role['title'];
01035 }
01036 $selectElement = ilUtil::formSelect($current_default_role,
01037 "soap[user_default_role]", $roles, false, true);
01038
01039 $this->tpl->setVariable("SOAP_USER_DEFAULT_ROLE", $selectElement);
01040 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01041 $this->tpl->setVariable("COLSPAN", 3);
01042 $this->tpl->setVariable("TXT_SOAP_TITLE", $this->lng->txt("auth_soap_auth"));
01043 $this->tpl->setVariable("TXT_SOAP_DESC", $this->lng->txt("auth_soap_auth_desc"));
01044 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
01045 $this->tpl->setVariable("TXT_SOAP_ACTIVE", $this->lng->txt("active"));
01046 $this->tpl->setVariable("TXT_SOAP_SERVER", $this->lng->txt("server"));
01047 $this->tpl->setVariable("TXT_SOAP_SERVER_DESC", $this->lng->txt("auth_soap_server_desc"));
01048 $this->tpl->setVariable("TXT_SOAP_PORT", $this->lng->txt("port"));
01049 $this->tpl->setVariable("TXT_SOAP_PORT_DESC", $this->lng->txt("auth_soap_port_desc"));
01050 $this->tpl->setVariable("TXT_SOAP_URI", $this->lng->txt("uri"));
01051 $this->tpl->setVariable("TXT_SOAP_URI_DESC", $this->lng->txt("auth_soap_uri_desc"));
01052 $this->tpl->setVariable("TXT_SOAP_NAMESPACE", $this->lng->txt("auth_soap_namespace"));
01053 $this->tpl->setVariable("TXT_SOAP_NAMESPACE_DESC", $this->lng->txt("auth_soap_namespace_desc"));
01054 $this->tpl->setVariable("TXT_USE_DOTNET", $this->lng->txt("auth_soap_use_dotnet"));
01055 $this->tpl->setVariable("TXT_USE_HTTPS", $this->lng->txt("auth_soap_use_https"));
01056 $this->tpl->setVariable("TXT_CREATE_USERS", $this->lng->txt("auth_create_users"));
01057 $this->tpl->setVariable("TXT_CREATE_USERS_DESC", $this->lng->txt("auth_soap_create_users_desc"));
01058 $this->tpl->setVariable("TXT_ACCOUNT_MAIL", $this->lng->txt("user_send_new_account_mail"));
01059 $this->tpl->setVariable("TXT_ACCOUNT_MAIL_DESC", $this->lng->txt("auth_new_account_mail_desc"));
01060 $this->tpl->setVariable("TXT_SOAP_USER_DEFAULT_ROLE", $this->lng->txt("auth_user_default_role"));
01061 $this->tpl->setVariable("TXT_SOAP_USER_DEFAULT_ROLE_DESC",
01062 $this->lng->txt("auth_soap_user_default_role_desc"));
01063 $this->tpl->setVariable("TXT_ALLOW_LOCAL", $this->lng->txt("auth_allow_local"));
01064 $this->tpl->setVariable("TXT_ALLOW_LOCAL_DESC", $this->lng->txt("auth_soap_allow_local_desc"));
01065 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01066 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01067 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01068 $this->tpl->setVariable("CMD_SUBMIT", "saveSOAP");
01069 }
01070
01076 function saveSOAPObject()
01077 {
01078 global $ilUser, $ilSetting;
01079
01080
01081 if (!$_POST["soap"]["server"])
01082 {
01083 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
01084 }
01085
01086
01087 if ($_POST["soap"]["server"] != "" && (preg_match("/^[0-9]{0,5}$/",$_POST["soap"]["port"])) == false)
01088 {
01089 $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
01090 }
01091
01092 $ilSetting->set("soap_auth_server", $_POST["soap"]["server"]);
01093 $ilSetting->set("soap_auth_port", $_POST["soap"]["port"]);
01094 $ilSetting->set("soap_auth_active", $_POST["soap"]["active"]);
01095 $ilSetting->set("soap_auth_uri", $_POST["soap"]["uri"]);
01096 $ilSetting->set("soap_auth_namespace", $_POST["soap"]["namespace"]);
01097 $ilSetting->set("soap_auth_create_users", $_POST["soap"]["create_users"]);
01098 $ilSetting->set("soap_auth_allow_local", $_POST["soap"]["allow_local"]);
01099 $ilSetting->set("soap_auth_account_mail", $_POST["soap"]["account_mail"]);
01100 $ilSetting->set("soap_auth_use_https", $_POST["soap"]["use_https"]);
01101 $ilSetting->set("soap_auth_use_dotnet", $_POST["soap"]["use_dotnet"]);
01102 $ilSetting->set("soap_auth_user_default_role", $_POST["soap"]["user_default_role"]);
01103 sendInfo($this->lng->txt("auth_soap_settings_saved"),true);
01104
01105 $this->ctrl->redirect($this,'editSOAP');
01106 }
01107
01113 function editScriptObject()
01114 {
01115 global $rbacsystem;
01116
01117 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
01118 {
01119 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01120 }
01121
01122 if ($_SESSION["error_post_vars"])
01123 {
01124 $this->tpl->setVariable("AUTH_SCRIPT_NAME", $_SESSION["error_post_vars"]["auth_script"]["name"]);
01125 }
01126 else
01127 {
01128
01129 $settings = $this->ilias->getAllSettings();
01130
01131 $this->tpl->setVariable("AUTH_SCRIPT_NAME", $settings["auth_script_name"]);
01132 }
01133
01134 $this->getTemplateFile("script");
01135
01136 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01137 $this->tpl->setVariable("COLSPAN", 3);
01138 $this->tpl->setVariable("TXT_AUTH_SCRIPT_TITLE", $this->lng->txt("auth_script_configure"));
01139 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
01140 $this->tpl->setVariable("TXT_AUTH_SCRIPT_NAME", $this->lng->txt("auth_script_name"));
01141
01142 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01143 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01144 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01145 $this->tpl->setVariable("CMD_SUBMIT", "saveScript");
01146 }
01147
01153 function saveScriptObject()
01154 {
01155
01156 if (!$_POST["auth_script"]["name"])
01157 {
01158 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
01159 }
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171 $this->ilias->setSetting("auth_script_name", $_POST["auth_script"]["name"]);
01172 $this->ilias->setSetting("auth_mode", AUTH_SCRIPT);
01173
01174 sendInfo($this->lng->txt("auth_mode_changed_to")." ".$this->getAuthModeTitle(),true);
01175 $this->ctrl->redirect($this,'editScript');
01176 }
01177
01183 function editRADIUSObject()
01184 {
01185 global $rbacsystem, $rbacreview;
01186
01187 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
01188 {
01189 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01190 }
01191
01192 $this->__initSubTabs("editRADIUS");
01193
01194 if ($_SESSION["error_post_vars"])
01195 {
01196 if ($_SESSION["error_post_vars"]["radius"]["active"] == "1")
01197 {
01198 $this->tpl->setVariable("CHK_RADIUS_ACTIVE", "checked=\"checked\"");
01199 }
01200
01201 $this->tpl->setVariable("RADIUS_SERVER", $_SESSION["error_post_vars"]["radius"]["server"]);
01202 $this->tpl->setVariable("RADIUS_SHARED_SECRET", $_SESSION["error_post_vars"]["radius"]["shared_secret"]);
01203 }
01204 else
01205 {
01206
01207 $settings = $this->ilias->getAllSettings();
01208
01209 if ($settings["radius_active"] == "1")
01210 {
01211 $this->tpl->setVariable("CHK_RADIUS_ACTIVE", "checked=\"checked\"");
01212 }
01213
01214 include_once('classes/class.ilRADIUSAuthentication.php');
01215 $servers =ilRADIUSAuthentication::_getServers();
01216
01217 $this->tpl->setVariable("RADIUS_SERVER", implode(",",$servers));
01218 $this->tpl->setVariable("RADIUS_SHARED_SECRET", $settings["radius_shared_secret"]);
01219
01220 if (empty($settings["radius_port"]))
01221 {
01222 $this->tpl->setVariable("RADIUS_PORT", RADIUS_DEFAULT_PORT);
01223 }
01224 else
01225 {
01226 $this->tpl->setVariable("RADIUS_PORT", $settings["radius_port"]);
01227 }
01228 }
01229
01230 $this->getTemplateFile("radius");
01231
01232 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
01233 $this->tpl->setVariable("COLSPAN", 2);
01234 $this->tpl->setVariable("TXT_RADIUS_TITLE", $this->lng->txt("auth_radius_configure"));
01235 $this->tpl->setVariable("TXT_RADIUS_ACTIVE", $this->lng->txt("auth_radius_enable"));
01236 $this->tpl->setVariable("TXT_OPTIONS", $this->lng->txt("options"));
01237 $this->tpl->setVariable("TXT_RADIUS_SERVER", $this->lng->txt("auth_radius_server"));
01238 $this->tpl->setVariable("TXT_RADIUS_SHARED_SECRET", $this->lng->txt("auth_radius_shared_secret"));
01239 $this->tpl->setVariable("TXT_RADIUS_PORT", $this->lng->txt("auth_radius_port"));
01240
01241 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
01242 $this->tpl->setVariable("TXT_RADIUS_SERVER_DESC", $this->lng->txt("auth_radius_server_desc"));
01243 $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
01244 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("save"));
01245 $this->tpl->setVariable("CMD_SUBMIT", "saveRADIUS");
01246 }
01247
01253 function saveRADIUSObject()
01254 {
01255 global $ilUser;
01256
01257
01258 if (!$_POST["radius"]["server"] or !$_POST["radius"]["shared_secret"] or !$_POST["radius"]["port"])
01259 {
01260 $this->ilias->raiseError($this->lng->txt("fill_out_all_required_fields"),$this->ilias->error_obj->MESSAGE);
01261 }
01262
01263
01264 if ((preg_match("/^[0-9]{0,5}$/",$_POST["radius"]["port"])) == false)
01265 {
01266 $this->ilias->raiseError($this->lng->txt("err_invalid_port"),$this->ilias->error_obj->MESSAGE);
01267 }
01268
01269 include_once('classes/class.ilRADIUSAuthentication.php');
01270 if (!ilRADIUSAuthentication::_validateServers($_POST["radius"]["server"]))
01271 {
01272 $this->ilias->raiseError($this->lng->txt("err_invalid_server"),$this->ilias->error_obj->MESSAGE);
01273 }
01274
01275
01276 ilRADIUSAuthentication::_saveServers($_POST["radius"]["server"]);
01277 $this->ilias->setSetting("radius_shared_secret", $_POST["radius"]["shared_secret"]);
01278 $this->ilias->setSetting("radius_port", $_POST["radius"]["port"]);
01279 $this->ilias->setSetting("radius_active", $_POST["radius"]["active"]);
01280
01281 sendInfo($this->lng->txt("auth_radius_settings_saved"),true);
01282 $this->ctrl->redirect($this,'editRADIUS');
01283 }
01284
01291 function getAuthModeTitle()
01292 {
01293 switch ($this->ilias->getSetting("auth_mode"))
01294 {
01295 case AUTH_LOCAL:
01296 return $this->lng->txt("auth_local");
01297 break;
01298
01299 case AUTH_LDAP:
01300 return $this->lng->txt("auth_ldap");
01301 break;
01302
01303 case AUTH_SHIBBOLETH:
01304 return $this->lng->txt("auth_shib");
01305 break;
01306
01307 case AUTH_RADIUS:
01308 return $this->lng->txt("auth_radius");
01309 break;
01310
01311 case AUTH_SCRIPT:
01312 return $this->lng->txt("auth_script");
01313 break;
01314
01315 default:
01316 return $this->lng->txt("unknown");
01317 break;
01318 }
01319 }
01320
01321 function updateAuthRolesObject()
01322 {
01323 global $rbacsystem;
01324
01325 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
01326 {
01327 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
01328 }
01329
01330 include_once('classes/class.ilObjRole.php');
01331 ilObjRole::_updateAuthMode($_POST['Fobject']);
01332
01333 sendInfo($this->lng->txt("auth_mode_roles_changed"),true);
01334 $this->ctrl->redirect($this,'authSettings');
01335 }
01336
01337 function &executeCommand()
01338 {
01339 $next_class = $this->ctrl->getNextClass($this);
01340 $cmd = $this->ctrl->getCmd();
01341 $this->prepareOutput();
01342
01343
01344 switch($next_class)
01345 {
01346 case 'ilregistrationsettingsgui':
01347
01348 include_once './Services/Registration/classes/class.ilRegistrationSettingsGUI.php';
01349
01350
01351 $this->__initSubTabs('');
01352 $this->tabs_gui->setTabActive('settings');
01353 $this->tabs_gui->setSubTabActive('registration_settings');
01354
01355 $registration_gui =& new ilRegistrationSettingsGUI();
01356 $this->ctrl->forwardCommand($registration_gui);
01357 break;
01358
01359 case 'ilpermissiongui':
01360 include_once("./classes/class.ilPermissionGUI.php");
01361 $perm_gui =& new ilPermissionGUI($this);
01362 $ret =& $this->ctrl->forwardCommand($perm_gui);
01363 break;
01364
01365 default:
01366 if(!$cmd)
01367 {
01368 $cmd = "authSettings";
01369 }
01370 $cmd .= "Object";
01371 $this->$cmd();
01372
01373 break;
01374 }
01375 return true;
01376 }
01377
01378
01379 function __initSubTabs($a_cmd)
01380 {
01381 $shib = ($a_cmd == 'editSHIB') ? true : false;
01382 $ldap = ($a_cmd == 'editLDAP') ? true : false;
01383 $radius = ($a_cmd == 'editRADIUS') ? true : false;
01384 $cas = ($a_cmd == 'editCAS') ? true : false;
01385 $soap = ($a_cmd == 'editSOAP') ? true : false;
01386 $overview = ($a_cmd == 'authSettings' or $a_cmd == '') ? true : false;
01387
01388 include_once('classes/class.ilTabsGUI.php');
01389
01390 $this->tabs_gui->addSubTabTarget('registration_settings',
01391 $this->ctrl->getLinkTargetByClass('ilregistrationsettingsgui','view'));
01392
01393 $this->tabs_gui->addSubTabTarget("authentication_settings", $this->ctrl->getLinkTarget($this, "authSettings"),
01394 "", "", "", $overview);
01395 $this->tabs_gui->addSubTabTarget("auth_ldap", $this->ctrl->getLinkTarget($this, "editLDAP"),
01396 "", "", "", $ldap);
01397 $this->tabs_gui->addSubTabTarget("auth_shib", $this->ctrl->getLinkTarget($this, "editSHIB"),
01398 "", "", "", $shib);
01399 $this->tabs_gui->addSubTabTarget("auth_cas", $this->ctrl->getLinkTarget($this, "editCAS"),
01400 "", "", "", $cas);
01401 $this->tabs_gui->addSubTabTarget("auth_radius", $this->ctrl->getLinkTarget($this, "editRADIUS"),
01402 "", "", "", $radius);
01403 $this->tabs_gui->addSubTabTarget("auth_soap", $this->ctrl->getLinkTarget($this, "editSOAP"),
01404 "", "", "", $soap);
01405 }
01406 }
01407 ?>