修改 pLog 認證方式記事
pLog 是個優秀的軟體,採用 MVC 設計理念,讓網頁展現的部份可以獨立出來,符合了 BLog 個人化的特性,plugin 的功能使得 BLog 附加的功能具彈性容易擴展。
但如要對特定 user 申請限制時,目前並沒有可用的方式,因此我自已修改了 pLog 認證的程式,可以讓申請者和台中縣網既有的 LDAP 帳號做整合。
1.修改 class/dao/users.class.php
這個部份為登入時認證,必須是單位的使用者才可進入。
function authenticateUser( $user, $pass )
{
// 呼叫自訂的認證函式
if(!$this->tcc_ldap_check($user,$pass))
return false;
....
// 自訂的認證函式
function tcc_ldap_check($user,$pass){
$check_result = false;
// 判斷是否為單位的使用者
......
return $check_result;
}
2. 修改 class/summary/action/dousercreation.class.php
這個部份是註冊時的檢查,只有單位的使用者才可申請。
.....
function perform()
{
// if all data is correct, then we can proceed and use it
$tf = new Textfilter();
$this->userName = $tf->filterAllHTML($this->_request->getValue( "userName" ));
....
$this->_view = new SummaryView( "registerstep1" );
$this->_view->setErrorMessage( $this->_locale->tr("error_passwords_dont_match"));
$this->_form->setFieldValidationStatus( "userPasswordCheck", false );
$this->setCommonData( true );
return false;
}
//檢查是否為台中縣教職員
if (!$users->tcc_ldap_check($this->userName,$this->userPassword)){
$this->_view->setErrorMessage('抱歉! 本網誌謹限台中縣教職員申請!');
$this->_form->setFieldValidationStatus( "userName", false );
$this->setCommonData( true );
return false;
}
// if everything went fine, then proceed
$this->_view = new doBlogRegistrationView();
$this->setValues();
$this->setCommonData();
return true;
}
}
Hami大大您好,拜讀大作,請教LifeType和LDAP整合後,密碼可以同步嗎?看了一下您修改的程式碼好像只有做身分的檢查認證,只要縣網有帳號,且密碼正確就可以申請是嗎?
小弟想把LifeType的帳號密碼和LDAP同步,不知可不可行?請多指教,謝謝!
另外針對判斷是否為ldap用者的程式碼部分,不之能不能公開?小弟對程式不太熟悉,非常感激!
// 判斷是否為單位的使用者
......
return $check_result;