2013-10-31 39 views
7

我使用現有的Active Directory信息創建公司目錄。我能夠提取所需的所有數據,但我也想使用Active Directory作爲照片。如何使用ColdFusion顯示Active Directory jpegPhoto?

我發現這個代碼片段在這個博客:http://plus10.blogspot.com/2008/02/coldfusion-cfldap-display-images-stored.html

<!--- imageFile.cfm ---> 

<cfsilent> 

<cfldap action="QUERY" 
name="ldap" 
attributes="jpegPhoto" 
start="dc=[yourdc],dc=com" 
filter="sAMAccountName=[loginname]" 
server="[yourserver]" 
username="[username]" 
password="[password]"> 

<cfscript> 
    ldapPhoto = toString(ldap.jpegPhoto); 
    ldapPhoto = binaryDecode(ldapPhoto,"base64"); 
</cfscript> 

</cfsilent><cfcontent type="image/jpeg" variable="#ldapPhoto#"> 


<!--- to display the image on a page ---> 

<img src="imageFile.cfm" width="100" height="125" alt=""> 

我在我所有的服務器數據堵塞,我得到的錯誤

的形象」 ...... imagefile.cfm 「無法顯示,因爲它包含錯誤

爲什麼圖像不顯示?以及如何更正代碼?

我對查詢做了<cfdump>,它只是顯示爲「jpegPhoto」而非二進制數據。

我無法發佈實際頁面,因爲它只在內部網絡上。

+0

Nevermind!我更換了所有的代碼(除查詢)與

+9

你能可以繼續併發佈一個「答案」(這是允許的)。這樣,對於有同樣問題的其他人來說,這一點將更加明顯。另外,人們也可以投票。 – Leigh

回答

1

注意,海報回答了她自己的問題。 cfcontentimg標籤應該使用source屬性替換爲cfimage標籤,並且action =「writeToBrowser」