/** * Will get called before the login page is shown. * */ function loginpage_hook() { //$user, $frm, $errormsg defined in /login/index.php for overriding by loginpage_hooks for SSO or providing fake info global $CFG, $SESSION, $user, $frm, $DB; if (!isloggedin() or isguestuser()) { // guestuser or not-logged-in users // First, let's remember where we were trying to get to before we got here $this->set_wants_URL(); //for debugging purposes if ($this->debug_mode) { if (!empty($_GET['username'])) { $_SERVER["REMOTE_USER"] = $_GET['username']; } } /* * If we have a remote user value then pubcookie authenticated successfully. * We should process the REMOTE_USER */ if (!empty($_SERVER["REDIRECT_REMOTE_USER"])) { $_SERVER["REMOTE_USER"] = $_SERVER["REDIRECT_REMOTE_USER"]; } if (!empty($_SERVER["REMOTE_USER"])) { $username = $_SERVER["REMOTE_USER"]; //does the username need proccessing? if ($this->config->pubcookie_ldap_enable_lookup) { try { $ims = new IMS($this->config->pubcookie_ldap_bind_user, $this->config->pubcookie_ldap_bind_password, $this->config->pubcookie_ldap_bind_cn, $this->config->pubcookie_ldap_bind_rdn, $this->config->pubcookie_ldap_bind_url); } catch (Exception $e) { debugging("IMS authentication failed " . $e->getMessage(), DEBUG_DEVELOPER); return; } try { $user_info = $ims->get_user_info($username, $this->config->pubcookie_user_ldap_search_string, $this->config->pubcookie_user_ldap_rdn, $this->config->pubcookie_user_ldap_filter, array($this->config->pubcookie_user_ldap_scope)); //if the userinfo is valid standard user data then setup the temp_user if ($this->validate_standard_userinfo($user_info)) { //use employeenumber for username list($user, $frm) = $this->process_standard_user_login($user_info, $user_info->employeenumber); } else { //if the userinfo isn't valid standard user data if ($this->config->pubcookie_secondary_user_ldap_enable_lookup) { //check for valid secondary user data, uses a second query because we allow separate search settings for secondary users $user_info = $ims->get_user_info($username, $this->config->pubcookie_secondary_user_ldap_search_string, $this->config->pubcookie_secondary_user_ldap_rdn, $this->config->pubcookie_secondary_user_ldap_filter, array($this->config->pubcookie_secondary_user_ldap_scope)); if ($this->validate_secondary_userinfo($user_info)) { //check if the user exists in system. if so create the temp_user list($user, $frm) = $this->process_secondary_user_login($user_info, $user_info->uid); } } else { debugging("Secondary user ldap lookup not enabled", DEBUG_DEVELOPER); } } } catch (Exception $e) { debugging("Pubcookie: Exception caught " . $e->getMessage(), DEBUG_DEVELOPER); } //close the ims object $ims->close(); } else { //do login w/o ldap $user_info = new IMSRole(); //we require at a minimum a uid $user_info->uid = $username; //use secondary as we cannot create a new user without info list($user, $frm) = $this->process_secondary_user_login($user_info, $username, false); } } } }
function RWSLIMUser($r_usrn, $r_pw, $r_csf) { global $RWSECAS; /*********** eClass Modification ************ Extra Comments: LDAP lookup call for the employee id translation for ccid CCID->empid, this is needed because the authentication fails and tries to create a user. ************/ global $CFG; require_once $CFG->dirroot . '/local/eclass/lib/IMS.php'; $ims = new IMS($r_usrn, $r_pw, 'uid=', 'ou=people,dc=ualberta,dc=ca'); $user_info = $ims->get_user_info($r_usrn); $empid = $user_info->employeenumber; /*********** End eClass Modification ********/ if ($RWSECAS) { RWSPLICas($r_usrn, $r_pw, $r_csf); } //$r_usr = authenticate_user_login($r_usrn, $r_pw); $r_usr = authenticate_user_login($empid, $r_pw); //eClass Modification if ($r_usr) { complete_user_login($r_usr); } if (isloggedin()) { RWSSStat("1000"); } else { if ($RWSECAS) { if (isset($_SESSION['rwscas']['cookiejar'])) { $r_ckf = $_SESSION['rwscas']['cookiejar']; if (file_exists($r_ckf)) { unlink($r_ckf); } unset($_SESSION['rwscas']['cookiejar']); } unset($_SESSION['rwscas']); } RWSSErr("2008"); } }
* You should have received a copy of the GNU General Public License * along with The Pubcookie Moodle Auth Module. If not, see <http://www.gnu.org/licenses/>. */ define("MOODLE_INTERNAL", TRUE); require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; //Require Login to get course list global $PAGE, $CFG; $PAGE->set_context(context_system::instance()); require_login(); require_capability('moodle/site:config', context_system::instance()); require_once $CFG->dirroot . '/local/eclass/lib/IMS.php'; if (!empty($_REQUEST['ccid'])) { $pluginconfig = 'auth/pubcookie'; $config = get_config($pluginconfig); if (empty($config->pubcookie_ldap_bind_user) || empty($config->pubcookie_ldap_bind_password)) { debugging("ims_user or ims_password not set", DEBUG_DEVELOPER, array()); return; } else { if ($config->pubcookie_ldap_enable_lookup) { $ims = new IMS($config->pubcookie_ldap_bind_user, $config->pubcookie_ldap_bind_password, $config->pubcookie_ldap_bind_cn, $config->pubcookie_ldap_bind_rdn, $config->pubcookie_ldap_bind_url); $role = $ims->get_user_info($_REQUEST['ccid'], $config->pubcookie_user_ldap_search_string, $config->pubcookie_user_ldap_rdn, $config->pubcookie_user_ldap_filter, array($config->pubcookie_user_ldap_scope)); var_dump($role); } if ($config->pubcookie_secondary_user_ldap_enable_lookup) { $role = $ims->get_user_info($_REQUEST['ccid'], $config->pubcookie_secondary_user_ldap_search_string, $config->pubcookie_secondary_user_ldap_rdn, $config->pubcookie_secondary_user_ldap_filter, array($config->pubcookie_secondary_user_ldap_scope)); var_dump($role); } } } else { debugging("No user specified", DEBUG_DEVELOPER, array()); }