locked
Change Permissions on a List RRS feed

  • Question

  • Howdy,

    I have a workflow in place that creates a unique number system for a few different form libraries. I am using a single list to control all of the numbers. If the list doesn't exist, the workflow creates the list and adds the necessary fields. We need to lock this new list down so that it cannot be edited outside of the workflow. Here's what I have so far. The list does break inheritance but that's it, doesn't change permissions. Walking through the debugger shows everything runs. I'm guessing I'm working with the wrong set of objects for the list?

    listActNumbers.BreakRoleInheritance(true);
    listActNumbers.Update();
    foreach (SPRoleAssignment ra in listActNumbers.RoleAssignments)
    {
        while(ra.RoleDefinitionBindings.Count > 0)
            ra.RoleDefinitionBindings.Remove(0);
    
        ra.RoleDefinitionBindings.Add(web.RoleDefinitions["Read"]);
    }
    Thanks!
    David Lozzi
    Delphi Technology Solutions
    Blog
    • Moved by Mike Walsh FIN Wednesday, April 29, 2009 2:09 PM wf q (From:SharePoint - Development and Programming)
    Wednesday, April 29, 2009 1:38 PM

Answers

  • Fixed it... I was missing the all important Update

    listActNumbers.BreakRoleInheritance(true);
    
    listActNumbers.Update();
    
    foreach (SPRoleAssignment ra in listActNumbers.RoleAssignments)
    
    {
    
    
    
        while (ra.RoleDefinitionBindings.Count > 0)
    
            ra.RoleDefinitionBindings.Remove(0);
    
    
    
        ra.RoleDefinitionBindings.Add(web.RoleDefinitions["Read"]);
    
        ra.Update();
    
    }
    
    

    David Lozzi
    Delphi Technology Solutions
    Blog
    • Marked as answer by David Lozzi Wednesday, April 29, 2009 2:15 PM
    Wednesday, April 29, 2009 2:15 PM

All replies