85
85
function loginpage_hook() {
89
90
$site = get_site();
90
91
$CASform = get_string("CASform","auth");
91
92
$username = optional_param("username");
92
94
if (!empty($username)) {
95
if (strstr($SESSION->wantsurl,'ticket') || strstr($SESSION->wantsurl,'NOCAS'))
96
unset($SESSION->wantsurl);
102
// Test si cas activ� et param�tres non remplis
103
if (empty($this->config->hostname)) {
96
107
// Connection to CAS server
97
108
$this->connectCAS();
99
// Gestion de la connection CAS si acc�s direct d'un ent ou autre
110
// Gestion de la connection CAS si acc�s direct d'un ent ou autre
100
111
if (phpCAS::checkAuthentication()) {
101
112
$frm->username=phpCAS::getUser();
102
$frm->password="cas";
113
// if (phpCAS::getUser()=='esup9992')
114
// $frm->username='erhar0062';
115
$frm->password="passwdCas";
119
if ($_GET["loginguest"]== true) {
120
$frm->username="guest";
121
$frm->password="guest";
106
125
if ($this->config->multiauth) {
107
126
$authCAS = optional_param("authCAS");
108
if ($authCAS=="NOCAS")
127
if ($authCAS=="NOCAS")
111
130
// choice authentication form for multi-authentication
112
131
// test pgtIou parameter for proxy mode (https connection
113
132
// in background from CAS server to the php server)
114
133
if ($authCAS!="CAS" && !isset($_GET["pgtIou"])) {
115
print_header("$site->fullname: $CASform", $site->fullname, $CASform);
135
$navlinks[] = array('name' => $CASform, 'link' => null, 'type' => 'misc');
136
$navigation = build_navigation($navlinks);
138
print_header("$site->fullname: $CASform", $site->fullname, $navigation);
116
139
include($CFG->dirroot."/auth/cas/cas_form.html");
133
156
if ($this->config->logoutcas ) {
134
157
$backurl = $CFG->wwwroot;
135
158
$this->connectCAS();
136
phpCAS::logout($backurl);
159
phpCAS::logout($backurl);
140
* Connect to the cas (clientcas connection or proxycas connection
163
* Connect to the cas (clientcas connection or proxycas connection
142
165
* This function is called from admin/auth.php
198
221
function process_config($config) {
199
222
// set to defaults if undefined
201
if (!isset ($config->hostname))
224
if (!isset ($config->hostname))
202
225
$config->hostname = '';
203
if (!isset ($config->port))
226
if (!isset ($config->port))
204
227
$config->port = '';
205
if (!isset ($config->casversion))
228
if (!isset ($config->casversion))
206
229
$config->casversion = '';
207
if (!isset ($config->baseuri))
230
if (!isset ($config->baseuri))
208
231
$config->baseuri = '';
209
if (!isset ($config->language))
232
if (!isset ($config->language))
210
233
$config->language = '';
211
if (!isset ($config->use_cas))
212
$config->use_cas = '';
213
if (!isset ($config->proxycas))
234
if (!isset ($config->proxycas))
214
235
$config->proxycas = '';
215
if (!isset ($config->logoutcas))
236
if (!isset ($config->logoutcas))
216
237
$config->logoutcas = '';
217
238
if (!isset ($config->multiauth))
218
239
$config->multiauth = '';
255
276
set_config('casversion', $config->casversion, 'auth/cas');
256
277
set_config('baseuri', $config->baseuri, 'auth/cas');
257
278
set_config('language', $config->language, 'auth/cas');
258
set_config('use_cas', $config->use_cas, 'auth/cas');
259
279
set_config('proxycas', $config->proxycas, 'auth/cas');
260
280
set_config('logoutcas', $config->logoutcas, 'auth/cas');
261
281
set_config('multiauth', $config->multiauth, 'auth/cas');
469
489
function ldap_attributes () {
470
$fields = array("firstname", "lastname", "email", "phone1", "phone2",
471
"department", "address", "city", "country", "description",
472
"idnumber", "lang" );
473
490
$moodleattributes = array();
474
foreach ($fields as $field) {
491
foreach ($this->userfields as $field) {
475
492
if (!empty($this->config->{"field_map_$field"})) {
476
493
$moodleattributes[$field] = $this->config->{"field_map_$field"};
477
494
if (preg_match('/,/',$moodleattributes[$field])) {
678
695
// find users in DB that aren't in ldap -- to be removed!
679
696
// this is still not as scalable (but how often do we mass delete?)
680
697
if (!empty($this->config->removeuser)) {
681
$sql = "SELECT u.id, u.username, u.email
698
$sql = "SELECT u.id, u.username, u.email, u.auth
682
699
FROM {$CFG->prefix}user u
683
700
LEFT JOIN $temptable e ON u.username = e.username
684
701
WHERE u.auth='cas'
687
704
$remove_users = get_records_sql($sql);
688
705
if (!empty($remove_users)) {
689
706
print "User entries to remove: ". count($remove_users) . "\n";
691
707
foreach ($remove_users as $user) {
692
708
if ($this->config->removeuser == 2) {
693
//following is copy pasted from admin/user.php
694
//maybe this should moved to function in lib/datalib.php
695
$updateuser = new object();
696
$updateuser->id = $user->id;
697
$updateuser->deleted = 1;
698
$updateuser->username = addslashes("$user->email.".time()); // Remember it just in case
699
$updateuser->email = ''; // Clear this field to free it up
700
$updateuser->idnumber = ''; // Clear this field to free it up
701
$updateuser->timemodified = time();
702
if (update_record('user', $updateuser)) {
703
delete_records('role_assignments', 'userid', $user->id); // unassign all roles
704
//copy pasted part ends
709
if (delete_user($user)) {
705
710
echo "\t"; print_string('auth_dbdeleteuser', 'auth', array($user->username, $user->id)); echo "\n";
707
712
echo "\t"; print_string('auth_dbdeleteusererror', 'auth', $user->username); echo "\n";