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 361883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:11:31+00:00 2026-05-12T13:11:31+00:00

I am trying to modify certain properties for users in our active directory. Some

  • 0

I am trying to modify certain properties for users in our active directory. Some properties I can change and some I can’t. I am doing impersonation, but for some of the properties I still get the “General Access denied error” when I try to call CommitChanges().

For example this will work:

DirectoryEntry deUser = new DirectoryEntry(result.Path);

if (ImpersonateValidUser(adConnectionUsername, adConnectionDomain, adConnectionPassword))
{                    
    deUser.Properties["ampPasswordQuestion"].Value = newPasswordQuestion;
    deUser.Properties["ampPasswordAnswer"].Value = newPasswordAnswer;    
    deUser.CommitChanges();
    deUser.Close();

    UndoImpersonation();
}

This works presumably because we’ve manually added the properties into the AD schema with no access restrictions. (See ASP.NET 3.5 Security, Membership, and Role Management with C# and VB)

However if I try to modify something like the Comment property of a record as follows:

DirectoryEntry deUser = new DirectoryEntry(result.Path);

if (ImpersonateValidUser(adConnectionUsername, adConnectionDomain, adConnectionPassword))
{                    
    deUser.Properties["comment"].Value = comment;
    deUser.CommitChanges();
    deUser.Close();

    UndoImpersonation();
}

Then I will get “General access denied error”.

Anyone have any ideas?

The Impersionation code is from Microsoft found at: http://support.microsoft.com/kb/306158

  • 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-12T13:11:31+00:00Added an answer on May 12, 2026 at 1:11 pm

    I believe I have found the problem. Apparently you need to create the DirectoryEntry that will be modified after Impersonation is done. This seems to make sense because I believe the rights of the modifying user become effective at the creation of the entry to be modified. Can anyone verify this? I have not seen it explained this way in any documentation.

    I did some more testing and found out that the first entry does not even require Impersonation because the those attributes are not secured.

    In the 2nd case the following code works:

    if (ImpersonateValidUser(adConnectionUsername, adConnectionDomain, adConnectionPassword))
    {      
        DirectoryEntry deUser = new DirectoryEntry(result.Path);              
        deUser.Properties["comment"].Value = comment;
        deUser.CommitChanges();
        deUser.Close();
    
        UndoImpersonation();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to modify some HttpWebRequest functions, but I can't do it through
I'm trying to modify the decimal-format of a stylesheet based on certain information of
I'm trying to modify my GreaseMonkey script from firing on window.onload to window.DOMContentLoaded, but
I am trying to modify the output stream to search/replace some XHTML tags returned
I am trying to modify a Makefile, and I can't find the rule for
I'm trying to get a good idea on how to modify certain parts of
I'm trying to modify the class of an element if an ajax call based
I'm trying to modify the contents of an MSI file using Powershell. To do
I'm trying to modify the UI of a Redmine installation (Redmine 0.7.3.devel.2093 (MySQL)). When
Hi I'm trying to modify a web page so that it loads faster. Since

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.