ohh*_*hho 9 authentication drupal drupal-modules
我们将在公司内部网中部署一个Drupal站点.用户需要重置密码.我们有一个集中的密码重置机制(用于单点登录):
现在我们要将Drupal站点添加到所有系统.请建议一种通过外部程序更改Drupal登录密码的方法(假设系统可以在Drupal主机上运行脚本并编辑Drupal MySQL数据库).
小智 7
对于Drupal 7 - 希望这个自定义功能代码解析匿名用户的更改密码.
function password_reset(){
global $user;
$hashthepass = 'password'; /* Your password value*/
require_once DRUPAL_ROOT . '/' . variable_get('password_inc', 'includes/password.inc');
$hashthepass = user_hash_password(trim($hashthepass));
// Abort if the hashing failed and returned FALSE.
if (!$hashthepass) {
return FALSE;
}
else {
db_update('users')
->fields(array(
'pass' => $hashthepass
))
->condition('uid', $user->uid)
->execute();
}
}
Run Code Online (Sandbox Code Playgroud)
如果您使用的是 Drupal 6,那么系统中存储的密码就是密码的简单 md5。如果您使用 php 脚本触发密码重置,请使用http://php.net/manual/en/function.md5.php函数。
用户名和密码存储在users表中。md5 哈希值存储在该pass列中。
| 归档时间: |
|
| 查看次数: |
8920 次 |
| 最近记录: |