I
I
Ivan Trofimov2014-05-20 04:44:46
PHP
Ivan Trofimov, 2014-05-20 04:44:46

How to display photo from AD in browser (php + ldap)?

There is a small enterprise telephone directory in php that parses data from AD. Names, phone numbers and some more textual information are now displayed. I want to implement the output of photos of employees, in which direction to dig? How can I get links to these photos, or is it better to put them in a separate folder on the server using the crown and pick them up from there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2014-05-20
@Rsa97

$ldap = ldap_connect($ad_host);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind($ldap, $reader_rdn, $reader_pass);
$res = ldap_search($ldap, $base_dn, "($uid_attrib=".$_REQUEST['uid'].")", array('jpegPhoto'));
$info = ldap_get_entries($ldap, $res);
$photo = $info[0]['jpegphoto'][0];
$img = imagecreatefromstring($photo);
header("Content-type: image/jpeg");
imagejpeg($img,NULL,100);
lsap_close(ldap);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question