With a little bit of setup, you can have OTRS use this picture in the TicketZoom screen. We'll use the same trick found in How To use CustomerUser Map to link images (http-link).
While it is possible to embed an image right into the <img> tag, that would require code changes and is not supported by all browsers. So instead, what we're going to do is overload the URL for the attribute in the customer DB and point it to a script that will retrieve pictures from AD.
First, the script... but this in a file called "photo.php" (sorry it's in PHP instead of Perl... it's what I already have written):
Code: Select all
<?php
#Configuration options
$ldap_server = "dc.domain.net";
$ldap_user = "ldapuser@domain.net";
$ldap_pass = "password";
$dn = "dc=domain,dc=net";
# End config
$u = "";
if (isset($_GET['username']) and preg_match("/^[A-Za-z0-9]+$/", $_GET['username'])) {
$ldap = ldap_connect($ldap_server, 3268);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind($ldap, $ldap_user, $ldap_pass) or die ("No LDAP Bind to ".$ldap_server);
$filter = '(samaccountname='.$_GET['username'].')';
$sr = ldap_search($ldap, $dn, $filter, array('thumbnailphoto'));
$u = ldap_get_entries($ldap, $sr);
}
header('content-type: image/jpeg');
if (isset($u[0]['thumbnailphoto'])) {
echo $u[0]['thumbnailphoto'][0];
} else {
$fp = fopen('default.jpg', 'r');
fpassthru($fp);
}
?>
Once you can load the user's picture, then you want to add the option to the map in Config.pm.
Code: Select all
Map => [
# note: Login, Email and CustomerID needed!
# var, frontend, storage, shown, required, storage-type
[ 'UserLogin', 'Login', 'sAMAccountName', 1, 0, 'var', '#"><img width="96" height="96" src="http://yourserver.domain.net/path/photo.php?username=[% Data.UserLogin | uri %]" /></a><br /><a href="#', 0 ],
[ 'UserTitle', 'Title', 'title', 1, 0, 'var' ],
[ 'UserFirstname', 'Firstname', 'givenname', 0, 1, 'var' ],
[ 'UserLastname', 'Lastname', 'sn', 0, 1, 'var' ],
[ 'UserFullname', 'Name', 'displayName', 1, 1, 'var'],
[ 'UserEmail', 'Email', 'mail', 1, 0, 'var' ],
[ 'UserCustomerID', 'CustomerID', 'userPrincipalName', 0, 1, 'var' ],
[ 'UserPhone', 'Phone', 'telephonenumber', 1, 0, 'var' ],
[ 'UserCell', 'Cell', 'mobile', 1, 0, 'var' ],
[ 'UserAddress', 'Address', 'streetAddress', 1, 0, 'var' ],
],
Make sure you replace the URL for the image source to be the script you just set up.
In my environment, I also have a script that will search AD as an online phonelist (giving the same information that Outlook gives). Instead of the # marks above, I used the URL to that search ( http://phonesearch.domain.net/phonelist.php?samaccountname=$Data{"UserLogin"} ). This makes it so the picture (and the User ID below the picture) link to my phonelist search. Though in actuality, most of the information phonelist search returns is now available in OTRS. The main exception to that being the manager and direct reports.