=1)其中有一項密碼值通過驗證,則表示通過ldap驗證....">

亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 軟件項目管理 > 項目管理軟件 > 禪道項目管理軟件
給禪道用戶登陸函數成員,加入ldap驗證
作者:網絡轉載 發布時間:[ 2016/2/25 13:32:08 ] 推薦標簽:項目管理軟件 項目管理

  在/module/user/ext/model里新建identify.php,代碼如下:
public function identify($account, $password)
{
if(!$account or !$password) return false;
/**
*ldap驗證程序塊,其中目錄樹的uid可以取同一個值,只要返回的數組(count>=1)其中有一項密碼值通過驗證,則表示通過ldap驗證;
*系統則不在重復驗證密碼,但還要驗證用戶名,因為要檢查數據的完整性.
*----------------------------------------Start---------------------------------------------*/
$ldaphost="192.168.0.2";
$ldapport=389;
$ldapUid="cn=admin,dc=21com,dc=com";
$ldapPwd="318296";
$base_dn="dc=21com,dc=com";
$filter="uid=".$account;
$attributes=array("userPassword");
$ds=ldap_connect($ldaphost,$ldapport) or die(js::error($this->lang->user->loginFailed));
if($ds){
ldap_set_option ( $ds, LDAP_OPT_PROTOCOL_VERSION, 3 );
ldap_set_option ( $ds, LDAP_OPT_REFERRALS, 0 ); // Binding to ldap server
$bd = ldap_bind($ds, $ldapUid, $ldapPwd)  or die(js::error($this->lang->user->loginFailed));
$sr=ldap_search($ds, $base_dn, $filter,$attributes);
$count=ldap_count_entries($ds, $sr);
if($count>0){
$info=ldap_get_entries($ds, $sr);
$ispass=FALSE;
for($i=0;$i<$info['count'];$i++){
$arrpwd=$info[$i]['userpassword'];
if(in_array($password, $arrpwd)||in_array(md5($password), $arrpwd)){
$ispass=TRUE;
break;
}
}
if($ispass){//通過則進入系統用戶名驗證
$this->dao->update(TABLE_USER)->set('password')->eq(md5($password))->where('account')->eq($account)->exec();
}else{
die(js::error($this->lang->user->loginFailed));die(1);
}
}else{
die(js::error($this->lang->user->loginFailed));die(2);
}
ldap_unbind($ds);
}
ldap_close($ds);
/*-------------------------------------End------------------------------------------------*/
/* Get the user first. If $password length is 32, don't add the password condition.  */
$user = $this->dao->select('*')->from(TABLE_USER)
->where('account')->eq($account)
//->beginIF(strlen($password) < 32)->andWhere('password')->eq(md5($password))->fi()//不驗證密碼
//->andWhere('deleted')->eq(0)//不驗證用戶是否禁用
->fetch();
/* If the length of $password is 32 or 40, checking by the auth hash. */
if($user and strlen($password) == 32)
{
$hash = $this->session->rand ? md5($user->password . $this->session->rand) : $user->password;
$user = $password == $hash ? $user : '';
}
elseif($user and strlen($password) == 40)
{
$hash = sha1($user->account . $user->password . $user->last);
$user = $password == $hash ? $user : '';
}
if($user)
{
$ip   = $this->server->remove_addr;
$last = $this->server->request_time;
$this->dao->update(TABLE_USER)->set('visitsvisits = visits + 1')->set('ip')->eq($ip)->set('last')->eq($last)->where('account')->eq($account)->exec();
$user->last = date(DT_DATETIME1, $user->last);
}
return $user;
}
  有關禪道方法重寫的問題請參照禪道插件說明,下面有pdf。

軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 一级二级黄色片 | 美女视频黄的全免费网站 | 午夜a视频 | 大学生一级毛片全黄毛片黄 | 成人三级图片 | 香蕉成人999视频 | 国产视频一区在线播放 | 久草手机在线 | xxxxchina麻豆免费视频 | 日本三级视频在线观看 | 日日夜夜操天天干 | 99re在线精品视频 | 日韩不卡视频在线 | 十八成人网 | 欧美精彩视频在线观看 | 先锋影音在线资源669 | 亚洲sss综合天堂久久久 | www.黄色在线观看 | 国产亚洲精品福利在线 | 中文字幕精品在线视频 | 大伊人网 | 亚欧乱色视频 视频在线 | 久草久草久草久草 | 国产亚洲精品高清在线 | 黄色短视频免费观看 | 中国一级特黄毛片 | 看全色黄大色黄女片18 | 级毛片久久久毛片精品毛片 | 2019中文字幕在线 | 看片在线 | 色偷偷亚洲第一成人综合网址 | 国产成人成人一区二区 | 久久久性视频 | 欧美成人精品三级网站 | 欧美日韩中文在线 | 亚洲经典在线中文字幕 | 国产成人女人在线视频观看 | 丰满大胸五十路免费 | www中文字幕在线观看 | 欧美 日韩 国产在线 | 伊人中文|