Maks3w / FR3DLdapBundle

This bundle integrates LDAP Authentication with any user manager (Ex: FOSUserBundle)
119 stars 77 forks source link

LDAP create user only if needed and multiple auth provider #121

Closed vbeauvivre closed 8 years ago

vbeauvivre commented 8 years ago

I made those changes through class overiding in my application successfully, so I just wante to share this work.

Thanks for sharing this bundle.

Maks3w commented 8 years ago

About the changes on LegacyHydrator, this class is legacy and deprecated so I don't have plans to maintenance that class.

About the LdapException thrown I would like more details about what DN was used and tests. I suspect may be an issue in your implementation.

vbeauvivre commented 8 years ago

To reproduce the situation : -I installed a LDAP server with this DN : dc=ldap,dc=mydomain,dc=fr -I created a samba user with https://sourceforge.net/projects/phpldapadmin/ -I installed symfony + fos_user_bundle + FR3DLdapBundle -I configure it all, with only fos_user_bundle provider (in security.yml) only. Everything is ok : I connect with user in DB. -I configure it all, with only fr3d_ldapbundle provider (in security.yml) only. Everything is ok : I connect with LDAP user account. -I configure it all, with only a chain provider that includes LDAP (first), then FOS_USER providers (in security.yml). Everything is ok with LDAP account : I connect succefully and get fully authentified. But I cannot connect with my fos_user in db. In this case it throws me a Zend\Ldap\Exception\LdapException with message «LDAP_INVALID_DN_SYNTAX». Maybe because the $user->getDn() returns an empty string.

Maks3w commented 8 years ago
  1. Don't implement getDn and check if works.
  2. Then, try to reimplement getDn but return null if DN is unknown
vbeauvivre commented 8 years ago

Ok, that fix it !

But I do not understand about the LegacyHydrator. Should this class not be used ? Does that mean implementation need to overide fr3d_ldap.user_hydrator.default service ? or there is another way to define hyrator ? Thanks

Maks3w commented 8 years ago

The problem is there is no interfaces for setters, hydrators offer a bridge so you can set the data from LDAP in the user object.

LegacyHydrator has an opiniated way of use many setters and reduce the complexity of migrate from previous versions of this bundle.