2016-03-12 144 views
0

我有一個使用FOSUserBundle和FR3DLdapBundle進行註冊和配置的Symfony項目,但是當我對測試LDAP服務器進行身份驗證時,身份驗證有效,但是當我查看dev.log時,Doctrine插入語句沒有密碼(它是空白的)。已驗證的LDAP密碼未存儲在fos_user數據庫中

這是我config.yml文件的底部:

fr3d_ldap: 
    driver: 
     host: ldap.forumsys.com 
    user: 
     baseDn: dc=example, dc=com 
     attributes: 
      - { ldap_attr: uid, user_method: setUsername } 
      - { ldap_attr: mail, user_method: setEmail } 
      - { ldap_attr: userPassword, user_method: setPassword } 
     filter: (&(ObjectClass=person)) 

fos_user: 
    db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel' 
    firewall_name: main 
    user_class: AppBundle\Entity\User 

我使用這個在線的LDAP服務器來驗證:http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/

這裏是我的用戶等級:

/** 
* @ORM\Entity 
* @ORM\Table(name="fos_user") 
*/ 
class User extends BaseUser implements LdapUserInterface 
{ 
    /** 
    * @ORM\Id 
    * @ORM\Column(type="integer") 
    * @ORM\GeneratedValue(strategy="AUTO") 
    */ 
    protected $id; 

    /** 
    * @ORM\Column(type="string") 
    */ 
    protected $dn; 

    public function __construct() 
    { 
     parent::__construct(); 
     if (empty($this->roles)) { 
      $this->roles[] = 'ROLE_USER'; 
     } 
    } 

    /** 
    * {@inheritDoc} 
    */ 
    public function setDn($dn) 
    { 
     $this->dn = $dn; 
    } 

    /** 
    * {@inheritDoc} 
    */ 
    public function getDn() 
    { 
     return $this->dn; 
    } 
} 

的當我用例如「gauss」和密碼「password」登錄時,發生主要問題,dev.log顯示:

[2016-03-11 20:51:40] ldap_driver.DEBUG: {action}({base_dn}, {filter}, {attributes}) {"action":"ldap_search","base_dn":"dc=example, dc=com","filter":"(&(&(ObjectClass=person))(uid=gauss))","attributes":[]} [] 
[2016-03-11 20:51:41] security.INFO: User {username} {result} on LDAP {"action":"loadUserByUsername","username":"gauss","result":"found"} [] 
[2016-03-11 20:51:41] ldap_driver.DEBUG: {action}({bind_rdn}, ****) {"action":"ldap_bind","bind_rdn":"uid=gauss,dc=example,dc=com"} [] 
[2016-03-11 20:51:41] security.INFO: User has been authenticated successfully. {"username":"gauss"} [] 
[2016-03-11 20:51:41] doctrine.DEBUG: "START TRANSACTION" [] [] 
[2016-03-11 20:51:41] doctrine.DEBUG: INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) {"1":"gauss","2":"gauss","3":"[email protected]","4":"[email protected]","5":true,"6":"6amuldowmz0oo0ww00wwwgo0k408sc","7":"","8":"2016-03-11 20:51:41","9":false,"10":false,"11":null,"12":null,"13":null,"14":["ROLE_USER"],"15":false,"16":null} [] 
[2016-03-11 20:51:41] doctrine.DEBUG: "COMMIT" [] [] 

注意密碼爲空。我希望能夠獲得密碼(即使它來自表單)並將其存儲在數據庫中。我想知道如何做到這一點。

任何幫助/建議表示讚賞。

回答

1

如果您使用LDAP進行身份驗證,則不需要保存密碼。

+0

問題是,當我使用上述配置時,成功登錄一次後;那麼當我註銷並嘗試再次登錄時,它會顯示憑據不正確。我認爲它試圖使用數據庫密碼。你需要任何日誌嗎? –

+0

奇怪,我只是重新測試了登錄註銷登錄過程,現在它正在工作。它一定是我做的配置改變。感謝您的迴應! –