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        = "newperson@gmail.com";
$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, 可能会有其他的办法解决。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值