显示thumbnailPhoto从PHP的Active Directory [英] Display thumbnailPhoto from Active Directory in PHP

查看:569
本文介绍了显示thumbnailPhoto从PHP的Active Directory的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个系统来显示每个人的姓名,电子邮件从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马克   IIIðð2013:05:19 17:35:31š,à,è'0230ð'   '(0'8'''@''11''11 0100   YY¢^ h¢P¢¤¤¤¤2013:04:17   11:44:522013:04:17 11:44:52H¹o@B¬†   EdnäWμ~:Ì|®(¶   HHÿØÿàJFIFÿÛC$。   ,#(7),01444'9 = 82&其中;.342ÿÛC   2 !!22222222222222222222222222222222222222222222222222ÿÀ-DYA   ÿÄμ}!1AQaq2'¡·B±ARND $ 3房,   %&'()456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ   !ÿÄμw1AQaq2B'¡±A#3RðbrÑ$ 4A%N&放大器;'()

ÿØÿà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á%ñ&'()

这还不是全部的,但它是一个很长的字符串,我是presuming是某种类型的二进制字符串?

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 with the appropriate mime-type to the browser.

因此​​,像&LT; IMG SRC =数据:??为image / jpeg; BASE64,&LT; PHP base64en code($和imagestring);&GT;/&GT; 应该是可能的输出图像。

So something like <img src="data:image/jpeg;base64,<?php base64encode($imageString); ?>"/> should be possible to output that image.

但它可能也有可能把任何图片格式成 thumbnailPhoto -Attribute。因此,我把内容放到这个将被直接从服务器提供一个临时文件。为了得到正确的文件结尾,您将需要通过文件finfo 来获得正确的MIME类型。

But it might also be possible to put 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. To get the correct file-ending you will need to pass the file through finfo to get the correct mime-type.

所以,你可能做这样的事情:

So you might do something like this:

$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) . '"/>';

这篇关于显示thumbnailPhoto从PHP的Active Directory的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆