Note that there are some explanatory texts on larger screens.

plurals
  1. POInherit Active Directory permissions via C#
    primarykey
    data
    text
    <p><strong>Edit:</strong> It seems it doesn't work. Some permissions aren't copied over it seems. This is inside an Active Directory for Exchange 2010. In the screenshot, there's the user "RTCUniversalUserReadOnlyGroup", with the "permission" column empty. Those permissions don't get copied over at all. Any tips?</p> <p>I'm currently having to uncheck the "Include inheritable permissions from this object's parent" checkbox in Active Directory in a programmatic way.</p> <p>EDIT: Had to put the image back in URL form: <a href="http://i47.tinypic.com/2a8fed5.jpg" rel="nofollow noreferrer">http://i47.tinypic.com/2a8fed5.jpg</a></p> <p>I figured the way to actually uncheck it, but when you do it through the interface, it asks you if you want to copy the current permissions or remove them.</p> <p>Only way I found is to manually list the permissions, put them in a temporary variable and then re-add them after the checkbox was removed.</p> <pre><code> using (DirectoryEntry entry = new DirectoryEntry(myPath)) { List&lt;ActiveDirectoryAccessRule&gt; rules = new List&lt;ActiveDirectoryAccessRule&gt;(); foreach (object ruleObject in entry.ObjectSecurity.GetAccessRules(false, true, typeof(SecurityIdentifier))) { ActiveDirectoryAccessRule rule = ruleObject as ActiveDirectoryAccessRule; if (rule.IsInherited) { rules.Add(rule); } } foreach (object ruleObject in entry.ObjectSecurity.GetAccessRules(false, true, typeof(NTAccount))) { ActiveDirectoryAccessRule rule = ruleObject as ActiveDirectoryAccessRule; if (rule.IsInherited) { rules.Add(rule); } } entry.ObjectSecurity.SetAccessRuleProtection(true, false); foreach (var rule in rules) { entry.ObjectSecurity.AddAccessRule(rule); } entry.CommitChanges(); } </code></pre> <p>I'm wondering if there's a better way to do this and if I'm missing something. It seems to work fine for now, but it feels like a hack that will come bite me in the ass once the project will be deployed.</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.
 

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