当前位置: 首页>>代码示例>>PHP>>正文


PHP PassHash::hash_ssha方法代码示例

本文整理汇总了PHP中PassHash::hash_ssha方法的典型用法代码示例。如果您正苦于以下问题:PHP PassHash::hash_ssha方法的具体用法?PHP PassHash::hash_ssha怎么用?PHP PassHash::hash_ssha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PassHash的用法示例。


在下文中一共展示了PassHash::hash_ssha方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: modifyUser

 /**
  * Definition of the function modifyUser in order to modify the password
  *
  * @param   string $user    nick of the user to be changed
  * @param   array  $changes array of field/value pairs to be changed (password will be clear text)
  * @return  bool   true on success, false on error
  */
 function modifyUser($user, $changes)
 {
     // open the connection to the ldap
     if (!$this->_openLDAP()) {
         $this->_debug('LDAP cannot connect: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
         return false;
     }
     // find the information about the user, in particular the "dn"
     $info = $this->getUserData($user, true);
     if (empty($info['dn'])) {
         $this->_debug('LDAP cannot find your user dn', 0, __LINE__, __FILE__);
         return false;
     }
     $dn = $info['dn'];
     // find the old password of the user
     list($loginuser, $loginsticky, $loginpass) = auth_getCookie();
     if ($loginuser !== null) {
         // the user is currently logged in
         $secret = auth_cookiesalt(!$loginsticky, true);
         $pass = auth_decrypt($loginpass, $secret);
         // bind with the ldap
         if (!@ldap_bind($this->con, $dn, $pass)) {
             $this->_debug('LDAP user bind failed: ' . htmlspecialchars($dn) . ': ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
             return false;
         }
     } elseif ($this->getConf('binddn') && $this->getConf('bindpw')) {
         // we are changing the password on behalf of the user (eg: forgotten password)
         // bind with the superuser ldap
         if (!@ldap_bind($this->con, $this->getConf('binddn'), conf_decodeString($this->getConf('bindpw')))) {
             $this->_debug('LDAP bind as superuser: ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
             return false;
         }
     } else {
         return false;
         // no otherway
     }
     // Generate the salted hashed password for LDAP
     $phash = new PassHash();
     $hash = $phash->hash_ssha($changes['pass']);
     // change the password
     if (!@ldap_mod_replace($this->con, $dn, array('userpassword' => $hash))) {
         $this->_debug('LDAP mod replace failed: ' . htmlspecialchars($dn) . ': ' . htmlspecialchars(ldap_error($this->con)), 0, __LINE__, __FILE__);
         return false;
     }
     return true;
 }
开发者ID:janzoner,项目名称:dokuwiki,代码行数:53,代码来源:auth.php


注:本文中的PassHash::hash_ssha方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。