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()); }
/** * Processes the user_info as a secondary user type. Secondary users are only able to login if the account has already been created on the system. * @param $user_info * @param $username * @param bool $update * @return array */ private function process_secondary_user_login($user_info, $username, $update = true) { IMS::preprocess_user_info($user_info); //overrides global $user object in /login/index.php which completes the user login //we use empid as username now $user_temp = get_complete_user_data('username', $username); //based on username instead of empid, ccids can be mapped to multiple secondary ccids, but only one secondary exists. if (empty($user_temp)) { //only allow secondary CCIDs that are in system already return array(null, null); } //if the user doesn't exist if (empty($user_temp)) { return array(null, null); } else { $user = $user_temp; //to cause login/index.php to honor wantsurl $frm = new StdClass(); $frm->username = $username; if ($update) { $user = $this->update_user_from_user_info($user_info, $user); } return array($user, $frm); } }
/** * Converts the Returned LDAP search result object into a better organized IMSRole object * @param $info * @return IMSRole Object */ private function process_results($info) { $a_results = new IMSRole(); foreach ($info as $role) { //this check is to avoid non-roles, roles should always be arrays if (is_array($role)) { // $a_results = new IMSRole(); //go through each role foreach ($role as $role_attr_key => $role_attr_val) { //if its something we're looking for store it in the normal place if (property_exists($a_results, $role_attr_key)) { //its not a singlular property like a string if (is_array($role_attr_val)) { //if there are multiple values we'll store them as an array for the key. if (isset($role_attr_val['count']) && $role_attr_val['count'] > 1) { unset($role_attr_val['count']); IMS::check_and_combine($role_attr_val, $a_results->{$role_attr_key}); } else { IMS::check_and_combine($role_attr_val[0], $a_results->{$role_attr_key}); } } else { IMS::check_and_combine($role_attr_val, $a_results->{$role_attr_key}); } } else { $a_results->extra_fields[$role_attr_key] = $role_attr_val; } } } } return $a_results; }