ldap_set_option(LDAP_OPT_PROTOCOL_VERSION, 3);
(&(&(objectClass=user)(objectCategory=PERSON))(|(memberof=CN=Access-VPN-BitrixVM,OU=VPN,OU=Access,OU=Groups,OU=CO,DC=company,DC=local)(memberof=CN=Отдел клиентского сервиса \(Call-центр\),OU=Depart,OU=Groups,OU=CO,DC=company,DC=local)))
$result=ldap_search($adconn, $LDAP['dn'], $filter, $att);
if ($result) {
$info = ldap_get_entries($adconn, $result);
print $info["count"]." entries returned";
} else
print "LDAP search error ".ldap_errno($adconn)." (".ldap_error($adconn).")";
$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);