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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:49:32+00:00 2026-05-16T13:49:32+00:00

Using the System.DirectoryServices.Protocols namespace to add/modify attributes on an Active Directory group. Code: public

  • 0

Using the System.DirectoryServices.Protocols namespace to add/modify attributes on an Active Directory group. Code:

public void UpdateProperties(Dictionary<string, string> Properties) {

    List<DirectoryAttributeModification> directoryAttributeModifications;

    //  ... Code to convert Properties dictionary to directoryAttributeModifications
    //  There is one 'Add' modification, to set the 'description' of the group

    ModifyRequest modifyRequest = new ModifyRequest(groupDistinguishedName, directoryAttributeModifications.ToArray());
    modifyRequest.Controls.Add(new PermissiveModifyControl());
    ModifyResponse response = connection.SendRequest(modifyRequest) as ModifyResponse;

The PermissiveModifyControl is intended to keep the code from failing if the description already exists. The only information on PermissiveModifyControl I’ve found is here:
http://msdn.microsoft.com/en-us/library/bb332056.aspx

which states:

An LDAP modify request will normally fail if it attempts to add an attribute that already exists or if it attempts to delete an attribute that does not exist. With PermissiveModifyControl the modify operation succeeds without throwing a DirectoryOperationException error.

However, when the above code gets to the SendRequest(), it throws a DirectoryOperationException: “The attribute exists or the value has been assigned.”

What I’m trying to avoid is having to query every property in the collection being passed; if it exists, create a Replace DirectoryAttributeModification; if it doesn’t, create an Add instead. From what I can glean, PermissiveModifyControl is supposed to do just that.

Can anyone shed some light on why PermissiveModifyControl still throws a DirectoryOperationException, and how to properly use it?

Thanks in advance!
James

  • 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-16T13:49:33+00:00Added an answer on May 16, 2026 at 1:49 pm

    After some more experimenting, I’ve found that the documentation is misleading… you don’t want to add an attribute, you want to replace it (DirectoryAttributeOperation.Replace). If the attribute exists, it will of course replace it. If the attribute does not exist, it will create it.

    The rest of my code is correct.

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

Sidebar

Related Questions

I am using the System.DirectoryServices.Protocols functions to query an openldap directory. The openldap directory
We are experiencing a performance problem when communicating with the active directory using System.DirectoryServices.
We've implemented a Membership Provider that authenticates to Active Directory and it's using System.DirectoryServices.
I'm creating and updating Groups in Active Directory using the GroupPrincipal class in System.DirectoryServices.AccountManagement
I'm trying to execute the following code using System.DirectoryServices; public bool HasVirtualDirectory(string serverName, string
I'm using System.DirectoryServices.AccountManagement namespace classes to add and manage users in AD, but I
I'm using System.DirectoryServices to query active directory to authenticate/fetch users' info in a winforms
using System; using System.IO; using System.Reflection; using System.Text; using MyApp.Logging; namespace MyApp.SmsService.Common { public
using System; namespace FirstApplication { class Program { static void Main(params string[] args) {
I'm using the System.DirectoryServices.AccountManagement namespace classes to manage the membership of several groups. These

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.