Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's a series of blog postings with code that shows how to do it:</p> <p>(The first shows how to get a photo in, the second shows how to get it out)</p> <p><a href="http://blogs.technet.com/btrst4/archive/2004/08/30/222629.aspx" rel="noreferrer">Using the jpegPhoto attribute in AD - Part I</a></p> <p><a href="http://blogs.technet.com/btrst4/archive/2004/09/07/226323.aspx" rel="noreferrer">Using the jpegPhoto attribute in AD - Part II</a></p> <p><strong>EDIT:</strong> Here's a generic function implementing the code from Part I:</p> <pre><code>void AddPictureToUser( string strDN, // User Distinguished Name, in the form "CN=Joe User,OU=Employees,DC=company,DC=local" string strDCName, // Domain Controller, ie: "DC-01" string strFileName // Picture file to open and import into AD ) { // Open file System.IO.FileStream inFile = new System.IO.FileStream(strFileName, System.IO.FileMode.Open, System.IO.FileAccess.Read); // Retrive Data into a byte array variable byte[] binaryData = new byte[inFile.Length]; int bytesRead = inFile.Read(binaryData, 0, (int)inFile.Length); inFile.Close(); // Connect to AD System.DirectoryServices.DirectoryEntry myUser = new System.DirectoryServices.DirectoryEntry(@"LDAP://" + strDCName + @"/" + strDN); // Clear existing picture if exists myUser.Properties["jpegPhoto"].Clear(); // Update attribute with binary data from file myUser.Properties["jpegPhoto"].Add(binaryData); myUser.CommitChanges(); } </code></pre> <p><strong>EDIT:</strong> I found that in my organisation, the correct attribute to set was "thumbnailPhoto" like this:</p> <pre><code>myUser.Properties["thumbnailPhoto"].Add(binaryData); </code></pre> <p>This also seems to tbe the one that the commercial product <a href="http://www.exclaimer.com/" rel="noreferrer">Exclaimer</a> is setting (but it might be only doing that in my organization)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload