Symfony 2.6 FR3DLdapBundle. Authentication request could not be processed due to the system

Hello everyone, and I'm sorry if the question is dumb. I am very new to Symfony (2.6) and my first project requires a User to authenticate from AD.

Whatever I do, I keep getting: The authentication request could not be processed due to a system issue.

security.yml

encoders:
    FOS\UserBundle\Model\UserInterface: sha512


role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]

providers:
    chain_provider:
        chain:
            providers: [fos_userbundle, fr3d_ldapbundle]

    fr3d_ldapbundle:
        id: fr3d_ldap.security.user.provider

    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
main:

    pattern:    ^/
    fr3d_ldap:  ~
    form_login:
#         check_path: fos_user_security_check
#         login_path: fos_user_security_login
        always_use_default_target_path: true
        default_target_path: /main
        provider: chain_provider
    logout:
        path:   fos_user_security_logout
        target: /login
    anonymous: ~

access_control:
   - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }

      

config.yml

fr3d_ldap:
 driver:
  host:                192.168.137.200
  port:                50000
  username:            DOMAIN\Admnistrator    # Optional
  password:            pass_here    # Optional

user:
 baseDn: OU=HP,OU=MANA,DC=DOMAIN,DC=com
 filter: (&(ObjectClass=Person))
 attributes:          # Specify ldap attributes mapping [ldap attribute, user object method]
       - { ldap_attr: uid,  user_method: setUsername }
       - { ldap_attr: mail, user_method: setEmail }

      

Entity / Custom class

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

/**
* @ORM\Column(type="string", nullable=true)
*/
protected $name;

/**
* Ldap Object Distinguished Name
* @ORM\Column(type="string", length=128)
* @var string $dn
*/
private $dn;

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

public function setName($name) {
$this->name = $name;
}

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

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

      

If I don't implement LdapUserInterface, the DB authenticates fine, but always if I use anything other than mysql entries I get this error. could you help me? Appreciate this.

+3


source to share


2 answers


Try it on loginAction()

\Doctrine\Common\Util\Debug::dump($this->getDoctrine()->getEntityManager()->find('AppBundle:User', 1));

      



You might see an error. This works for me.

+1


source


Which fixed for me:

 implements UserInterface, \Serializable

      



to the end of my entity class declaration, then adding the necessary methods to the entity at the bottom:

/**
 * @return null
 */
public function getSalt(){
    return null;
}

/**
 * @return array
 */
public function getRoles(){
    return array('ROLE_USER');
}

public function eraseCredentials(){

}

/**
 * @return string
 */
public function serialize(){
    return serialize(array($this->id, $this->username, $this->password));
}

/**
 * @param string $serialized
 */
public function unserialize($serialized) {
    list($this->id, $this->username,$this->password) = unserialize($serialized);
}

      

+1


source







All Articles