-<?
- require_once('init.php');
- ldap_login();
+<?php
+require_once('inc/init.php');
+ldap_login();
- $dn = $_REQUEST['dn'];
+if ($conf['userlogreq'] && !isset($_SESSION['ldapab']['username'])){
+ header("HTTP/1.0 401 Access Denied");
+ echo '<h1>Access Denied</h1>';
+ exit();
+}
- $sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array('jpegPhoto'));
- if(!ldap_count_entries($LDAP_CON,$sr)){
- exit;
- }
- $result = ldap_get_binentries($LDAP_CON, $sr);
- $entry = $result[0];
+$dn = $_REQUEST['dn'];
- header("Content-type: image/jpeg");
- print $entry['jpegPhoto'][0];
+$sr = ldap_search($LDAP_CON,$dn,'(objectClass=inetOrgPerson)',array($FIELDS['photo']));
+if(!ldap_count_entries($LDAP_CON,$sr)){
+ header("HTTP/1.0 404 Not Found");
+ echo '<h1>Not Found</h1>';
+ exit;
+}
+$result = ldap_get_binentries($LDAP_CON, $sr);
+$entry = $result[0];
+
+header("Content-type: image/jpeg");
+print $entry[$FIELDS['photo']][0];
?>