Note that there are some explanatory texts on larger screens.

plurals
  1. POSharepoint: How to programmatically manage SPFolder and SPListItem permissions
    primarykey
    data
    text
    <p>I want to know if I'm missing something. Here's how I would do it: For SPFolder I would change the associtaed item's permissions (SPFolder.Item). So I suppose managing SPFolder permissions boils down to managing SPListItem permissions. For SPListItem I would frist break role inheritance with <code>SPListItem.BreakRoleInheritance()</code> and then work with <code>RoleAssignments</code> collections adding and removing roles there.</p> <p>I wonder if RoleAssignments is the only way to manage SPListItem's permissions (besides inheritance) and is there a way to manage individual permissions without roles. There is also EffectiveBasePermissions property but I'm not sure.</p> <p>So the question is is there other ways (besides inheritance) to manage SPListItem permissions apart from the RoleAssignments collection?</p> <p><strong>@Edit:</strong> there's also AllRolesForCurrentUser, but I guess you can get the same info from the RoleAssignments property, so this one is just for convenience.</p> <p><strong>@Edit:</strong> As Flo notes in his answer there is a problem with setting</p> <pre><code>folder.ParentWeb.AllowUnsafeUpdates = true; </code></pre> <p>And using <code>BreakRoleInheritance</code> with argument of 'false' (i.e. without copying permissions of the parent object).</p> <pre><code>folder.Item.BreakRoleInheritance(false); </code></pre> <p><code>BreakRoleInheritance</code> simply won't work on GET request as you'd expect after allowing unsafe updates. Presumably the method resets <code>AllowUnsafeUpdates</code> back to 'false'.</p> <p>One workaround I know for this is to manually delete the inherited permissions after you BreakRoleInheritance(true), like this:</p> <pre><code>folder.Item.BreakRoleInheritance(false); while(folder.Item.RoleAssignments.Count &gt; 0) { folder.Item.RoleAssignments.Remove(0); } </code></pre> <p>Thanks!</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