集成windows的域用户的验证的简单解决方案!给大家参考,水平有限,请帮忙优化!

qq_54f42ac924730 2015-03-02 20:27:02
  • 1、下载 adLDAP 4.0.4,下面附件有
  • 2、 解包放到这个位置
  • 3、修改adLDAP.php
  • 4、
  • 增加一个外挂函数
  •         public function compareHashPassword($password, $user)
    {
      
       $ldapusername = $this->post->account;
      if($ldapusername=='admin' )
      {
        /* Check Hash if password leng is 40. */
        $passwordLength = strlen($password);
        if($passwordLength == 40)
        {
            $hash = sha1($user->account . $user->password . strtotime($user->last));
            if($password == $hash) return true;
        }
        return $password == md5($user->password.$this->session->random);
      }
      else
      {
          $ldappassword = $this->post->oripassword;
          // $ad = ldap_connect("ldap://{$domain}");
            try {
              require_once(dirname(__FILE__) . '/adLDAP/src/adLDAP.php');
              $ad = new adLDAP();
              $authUser = $ad->authenticate($ldapusername, $ldappassword);
              if ($authUser == true)
              {
                  //  echo "User authenticated successfully";
                   $ad->close();
                   return true;
               }
              else
              {
               // getLastError is not needed, but may be helpful for finding out why:
                echo $ldapusername.$ldappassword.$ad->getLastError();
               // echo "User authentication unsuccessful";
                return false;
               }
            }
            catch (adLDAPException $e) {
            echo $ldappassword.$e;
            return false;
            }
      }
    }
    
    5、修改
  • login.js,增加一行和加点东西
回帖列表
kaogezi 2015-05-27 13:45:00
反反复复
wwccss 2015-03-04 08:14:19
qq_54f42ac924730 2015-03-03 12:46:43
这个怎么放,能把这个当例子,教下
wwccss 2015-03-03 12:19:45
可以只放你修改过的地方。:)
qq_54f42ac924730 2015-03-03 11:48:20
login.js,如果要放到ext里,需要整个放过去吗,因为现在这个做法,还是改动了原来的代码,对升级有影响 
wwccss 2015-03-03 09:28:41
帮你置顶下。:)
wwccss 2015-03-03 09:28:13
赞!感谢分享。
qq_54f42ac924730 2015-03-02 20:32:12

要在  php.ini中开启 ldap的扩展,重启服务;phpinfo();中没有ldap,可以看下面文章解决


http://blog.csdn.net/hhccth/article/details/8224900

1/ 1
鲁ICP备18054969号
ZSITE8.6