Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 535987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:46:29+00:00 2026-05-13T09:46:29+00:00

I need a method which will take an *.jpg image file and upload it

  • 0

I need a method which will take an *.jpg image file and upload it to a user profile in the Active Directory of Windows AD 2003.

Also a method to retrieve the photo as stream or expose it as secure web service to be called by cross platform apps in java etc (Damn! am I asking too much!!!)

The file being uploaded will be a *.jpg which is basically a visual signature file created by a user.

Does anyone having any experience working with Active Directory in C# provide some information as to how this can be done with minimum implication related to security.

From the point of view of the Windows Active Directory Administrator what does he have to
do to make this possible.Changes/provisions to schema of user profile etc.

The image is being uploaded so that it can be later retrieved from the AD to be inserted into PDF document for signature purposes.

Can this be done in C#? Or is there any done libraries etc?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:46:29+00:00Added an answer on May 13, 2026 at 9:46 am

    Here’s a series of blog postings with code that shows how to do it:

    (The first shows how to get a photo in, the second shows how to get it out)

    Using the jpegPhoto attribute in AD – Part I

    Using the jpegPhoto attribute in AD – Part II

    EDIT: Here’s a generic function implementing the code from Part I:

    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();
    }
    

    EDIT: I found that in my organisation, the correct attribute to set was “thumbnailPhoto” like this:

    myUser.Properties["thumbnailPhoto"].Add(binaryData);
    

    This also seems to tbe the one that the commercial product Exclaimer is setting (but it might be only doing that in my organization)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to write a method which will take a string like 1+2+3*4 and
I need to write a program, which will take an array of block pieces
i have a string and i need a utility method which looks for bad
I need this because the constructor in the superclass is calling a method which
I have a method which returns single word as a String. I need to
I need to know which method is called inside eclipse when I press CTRL
I need a method in JavaScript to escape all characters which are not (
I have a method myButtonAction which performs some heavy calculations, which I need to
I need to use method like: DoSomething<(T)>(); But i don't know which Type i
I have a method I need to unit test, which as the subject implies,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.