Q: How do I display Active Directory jpegPhoto with ColdFusion? I'm creating a company directory using our existing Active Directory information.  I'm able to pull all the data I need, but I wanted to use Active Directory for the photo as well.
I found this snippet of code on this blog: 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="">

I plugged in all my server data and I get the error

The image "....imagefile.cfm" cannot be displayed because it contains errors

Why isn't the image displaying? and how can I correct the code?
I did a <cfdump> on the query and it just shows as "jpegPhoto" not binary data.
I can't post the actual page because it is on an internal network only.

A: Note, the poster answered her own question.  The cfcontent and img tags should be replaced with a cfimage tag using the source attribute and action="writeToBrowser"

A: crediting the author: src: https://plus10.blogspot.com/2008/02/coldfusion-cfldap-display-images-stored.html

February 12, 2008
ColdFusion CFLDAP - Display images stored in Microsoft Active Directory
Not too hard once I found out how MS stores the data in the photoJpeg field of Active Directory.
<!--- 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="">

