Maks3w / FR3DLdapBundle

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

jpegPhoto doesn't trigger desired accessor #124

Closed Dragnucs closed 8 years ago

Dragnucs commented 8 years ago

If I set my config.yml like this:

fr3d_ldap:
    user:
        attributes:
            - { ldap_attr: jpegPhoto, user_method: setJpegPhoto }

Then setJpegPhoto() method is never called. Other methods are called just fine.

Maks3w commented 8 years ago

If the attribute does not exists then the method is not called. If you want to call it with a null value or whatever please create your own hydrator

https://github.com/Maks3w/FR3DLdapBundle/blob/master/Hydrator/HydrateWithMapTrait.php#L25-L27

Dragnucs commented 8 years ago

The attribute jpegPhoto does exists. The behaviour of the attributes mapping is not consistent with what you say; I have some users with a title defined and set, and some others with no title at all, completely missing, but its setter still gets called.

In the situation of jpegPhoto, which is a blob (I can't recall if I set it to text or string for testing purpose), the setJpegPhoto is never ever called. I even type some wrong PHP code to trigger an error, but the hydration happens while ignoring setJpegPhoto and jpegPhoto.

Never mind. I made a test to confirm my statements and it turns out LDAP is case sensitive, it is not globally case sensitive, only in some places. And to top it all, when dealing with it using Apache Directory studio, I have to write it exactly like jpegPhoto. Well maybe it is case insensitive everywhere but when PHP, which is case sensitive, maps the array with all lower-case keys it retrieved, that case-insensitivity is lost.

Can you please raise a warning or an error if a mapped attributed is not found? A warning like that could have saved days wasted.

Maks3w commented 8 years ago

LegacyHidrator is deprecated and is legacy. Use of this hydratoris discouraged