Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The common AD attribute for a user photo is <a href="http://msdn.microsoft.com/en-us/library/ms676813%28VS.85%29.aspx" rel="nofollow noreferrer">jpegPhoto</a> but you can use what ever name you want</p> <p>This sample shows the basic AD way to get and set an image stream. You need to flesh these methods out to be a useful class</p> <p>Consider making your web service to just return the URL of the image. The request handler for that URL should then return the image with the correct content type etc. Much more useful in a web environment</p> <pre><code>using System; using System.DirectoryServices; using System.Collections; using System.IO; public class ADPhoto { public void Set() { try { var de = new DirectoryEntry("LDAP://cn=username,cn=users,DC=domain, DC=com"); de.Username = "username"; de.Password = "password"; var forceAuth = de.NativeObject; var fs = new FileStream("path\\photo.jpg", FileMode.Open); var br = new BinaryReader(fs); br.BaseStream.Seek(0, SeekOrigin.Begin); byte[] ba = new byte[br.BaseStream.Length]; ba = br.ReadBytes((int)br.BaseStream.Length); de.Properties["jpegPhoto"].Insert(0, ba); de.CommitChanges(); } catch(Exception ex) { Console.WriteLine(ex.Message); } } public Stream Get() { var fs = new MemoryStream(); try { var de = new DirectoryEntry("LDAP://cn=username,cn=users,DC=domain, DC=com"); de.Username = "username"; de.Password = "password"; var forceAuth = de.NativeObject; var wr = new BinaryWriter(fs); byte[] bb = (byte[])de.Properties["jpegPhoto"][0]; wr.Write(bb); wr.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } return fs; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    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. 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.
    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