Moodl:集成密码,消除错误phpCAS error: phpCAS::client(): type mismatched for parameter $se

1. Generate Moodle password

 

For generating a moodle password , first of all include the the configuration page then use the script given below

$password = “new password”;
$moodle_password = md5($password.$CFG->passwordsaltmain);

 
$password is the actual password and the passwordsaltmain is a hash key generated at moodle installation.

 

原文: http://php-experts-code.blogspot.com/2011/03/generate-moodle-password.html

 

另一种方法是:

$moodle_password = hash_internal_user_password($password);

 

完全一样的效果!

 

2. phpCAS error: phpCAS::client(): type mismatched for parameter $server_version (should be `string') in C:\xmoodle\moodle\auth\cas\auth.php on line 170

 

这个关键在于属性"mnethostid", 这个值默认是0, 但是应该让其为1, 所以添加一个新的user,应该是:

$person               = new StdClass();
$person->auth         = 'manual';
$person->confirmed    = 1;
$person->mnethostid   = 1;  // 重点
$person->lastlogin    = time();
$person->currentlogin = time();

$person->username     = "newperson";
$person->password     = hash_internal_user_password('newperson');
//$person->idnumber   = $person->username;
$person->firstname    = "newperson";
$person->lastname     = "liang";
$person->email        = "[email protected]";
$person->city         = "sf";
$person->country      = "US";
$person->lang         = "en";

echo $person->id = $DB->insert_record('user', $person);

 

也可以去参考 https://moodle.org/mod/forum/discuss.php?d=73451, 可能会有其他的办法解决。

 

 

你可能感兴趣的:(parameter)