问题描述
我已经设置了一个系统来显示来自 Active Directory 的每个人的姓名、电子邮件地址和电话号码,但是我无法让thumbailPhoto"工作.
I've set up a system to display everyone's name, email address and phone number from Active Directory however I can't get the 'thumbailPhoto' to work.
我在互联网上四处搜索,但无法找到这是否可行,或者至少找不到从 Active Directory 返回的格式.
I have searched around on the internet but haven't been able to find if this is possible or at the very least what format is returned from Active Directory.
我目前正在使用 adldap 类,所以如果可以使用它,那将是理想的.
I am currently using the adldap class so if it is possible to use this that would be ideal.
提前致谢.
我可以在 thumbnailPhoto 属性中检索数据,如果我将它们直接转储到浏览器,我会得到如下信息:
I can retrieve the data in the thumbnailPhoto attribute and if I dump them straight to the browser I get something like this:
ÿØÿàJFIFððÿáPExifII*bh~†(2Ži‡¢XCanonCanon EOS 5D MarkIIIðð2013:05:19 17:35:31š‚à‚è"ˆ'ˆ 0230ð’' ' ('0'8' ' '@''11''11 0100ÿÿ¢H¢P¢¤¤¤¤ 2013:04:1711:44:522013:04:17 11:44:52H¹o@B¬†è»dnäWµ~:̦®(¶’HHÿØÿàJFIFÿÛC $.",#(7),01444'9=82<.342ÿÛC2!!22222222222222222222222222222222222222222222222222ÿÀ–d"ÿÄÿĵ}!1AQa"q2'¡#B±ÁRÑð$3br,%&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š'"•–~™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚÚáâãäåæçèéêñòóõöö÷øùùúÿĵw!1AQaq"2B'¡±Á #3RðbrÑ $4á%ñ&'()
ÿØÿàJFIFððÿá PExifII*bh~†(2Ži‡¢XCanonCanon EOS 5D Mark IIIðð2013:05:19 17:35:31š‚à‚è"ˆ'ˆ 0230ð’ ’ ’ (’0’8’ ’ ’@‘’11’’11 0100 ÿÿ¢H¢P¢¤¤¤¤ 2013:04:17 11:44:522013:04:17 11:44:52H¹o@B¬ † è»dnäWµ˜:̦®(¶’ HHÿØÿàJFIFÿÛC $.' ",#(7),01444'9=82<.342ÿÛC 2!!22222222222222222222222222222222222222222222222222ÿÀ–d"ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’""•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()
这还不是全部,但它是一个很长的字符串,我假设是某种二进制字符串?
That isn't all of it but it is a very long string, I am presuming is some sort of binary string?
推荐答案
这似乎是一个 JPEG 文件,因此您应该能够将该数据与适当的 mime 类型一起发送到浏览器.应该可以使用以下内容输出该图像:
This seems to be a JPEG-File, so you should be able to send that data together with the appropriate mime-type to the browser. It should be possible to output that image with something like:
<img src="data:image/jpeg;base64,<?php echo base64_encode($imageString); ?>"/>
但也可以将 any 图像格式的文件保存到该 thumbnailPhoto
属性中.因此,我会将内容放入一个临时文件中,然后直接从服务器提供该文件.您需要通过 finfo
传递文件以获得正确的 mime-type.
But it might also be possible to save files of any image format into that thumbnailPhoto
attribute. Therefore, I would put the content into a temporary file that will then be served directly from the server. You will need to pass the file through finfo
to get the correct mime-type.
所以你可以这样做:
$tempFile = tempnam(sys_get_temp_dir(), 'image');
file_put_contents($tempFile, $imageString);
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mime = explode(';', $finfo->file($tempFile));
echo '<img src="data:' . $mime[0] . ';base64,' . base64_encode($imageString) . '"/>';
这篇关于在 PHP 中显示来自 Active Directory 的缩略图照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!