Import photo from an LDAP directory

On some ldap directory, there's a standard attribute to store a picture for each user (OpenLdap & AD store it in jpegphoto).
We can retrieve and store this picture in glpi to show it on user relative informations :

  • User Form :
  • User Tooltips :

MoYo : question : is it interesting to always see the picture ? Just show thumbnail in form + tooltip to show complete picture ?
Alex : do you prefer an option do configure this ?
MoYo : no I think we just need to find the better solution for display. It was also a detail.

Changes :


  • We must add a field picture in glpi_users to retrieve the picture's path in GLPI
    CREATE TABLE `glpi_users` (
    `picture` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  • And also a new field in glpi_authldaps to store the related ldap attribute
    CREATE TABLE `glpi_authldaps` (
    `picture_field` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,

GLPI Folder structure

  • For storing pictures and their thumbnails, we can add a new folder files/_pictures
  • The user picture file can be named : userlogin.[png|jpg|...]
    • MoYo : to avoid problems with special characters : USERID.[png|jpg|...] may be more simple
      • After some tests, the userid is problematic. It is possible in synchronisation but on ldap first import, the current method User::getFromLdap can't have id. The user is created after retrieving dn in ldap and so no id is available yet.
      • MoYo : may do it on post_addItem() where id is available.
  • The thumbnail will be the picture filename prefixed by min.
    • MoYo : to permit simple management on filesystem (sort...) USERID_min.XXX may be better
    • Alex : same

Framework :

  • We must add the new field management in inc/authldap.class.php.
  • In this class, the fields retrieved are cleaned by get_entries_clean function. This call clean_cross_side_scripting_deep function which is provided for clean text (and no bytes datas). We must remove this picture field for cleaning (Furthermore, the picture is never stored in DB).
  • A thumbnail (75*75) created after downloading full size picture on user synchronisation (New fonction in Toolbox for resizing picture of any extension).
    • How create the thumbnail ? Which extension used ? Need more prerequisites ?
    • Alex : actually, the 4 popular extensions are managed (see :, xbm and xpm are also possible (but i don't know them)
    • MoYo : ok so GD required
    • Alex : yes, I can add a verification of the presence of library before adding image (and display an information message on form if absent)
    • MoYo : + need to have a check on install for information + add info on display if not available (another detail)
    • Alex : Is it not the current case ? GD is not required but necessary for statistic png displaying.
    • MoYo : yes it is. But think a check is missing on install / upgrade
  • The User->showForm must be reordered to display full size picture on right of the form.
  • This size of the full picture is limited by css (250*250px).
    • MoYo : Maybe smaller ? just a detail in fact
    • Alex : Maybe, in fact during my dev, i choose this size for fit with other fields
  • We provide the possibility to upload manually a picture in the user form.
  • This manual upload generate also a thumbnail after storing full size picture.
  • User tooltip can now contain the thumbnail. CSS is necessary to show it on text side.
  • The installation and migration scripts must be updated for DB changes.
  • An locale entry must be added for picture label (used in user form).

Misc :

  • The original ticket ( talks about base64 encoded jpeg. In my tests (openldap), I don't have found this encoding. The jpeg content was inline in ldap field. Maybe, we must provide a full text search to detect in header of ldap attribute for find the type of picture stored (if we find an ldap directory who store in base64 their pictures).
    • MoYo : maybe a first implementation. We will see in the future if other store system is used.
    • Alex : Ok
  • To keep consistency in the user form, user with no picture associated will have a default picture displayed.
  • This picture can be stored in standard pics folder

Current state of test developpments :

nopicture.png (47.2 KB) orthagh, 03/01/2013 01:56 PM

tooltip.png (44.7 KB) orthagh, 03/01/2013 02:40 PM

user_form.png (81.6 KB) orthagh, 03/01/2013 02:50 PM