Subscribe:      
 

How to Programmatically Set User And Group Permissions

Written By: Ivan Ivanov -- 10/5/2011 -- join -- contribute -- (0) comments -- printer friendly version

Rating: Rate --

Categories: Design, MOSS 2007, Permission Management, Programming and Customizations, Visual Studio, Web Parts, WSS3

< Prev - 1 | 2 | 3 | 4 | 5 | 6 | - Next > | Become a paid author


We have to override the OnPreRender method in order to populate departments in drop down list.

The next step is to implement btnOK_Click. We call the method AddItem to save a request in the list.



Now we have to deal with permissions. After submitting the request, the creator has to have only read permissions on item. The corresponding department manager has to have edit permissions. To fulfill these requirements we have to change the AddItem method as shown below. Actually we call the function GrantPermissionOnNew and declare variable _id.

The _id variable will store the ID of the new entered request. We call the function in context with elevated privileges because we have to set permissions and these actions require high privileges.
 


The implementation of GrantPermissionOnNew




In GrantPermissionOnNew we check the selected department and find the corresponding group. We grant that group Contribute permissions and the creator read permissions . Nobody else has any permissions. The first web part is completed.

< Prev - 1 | 2 | 3 | 4 | 5 | 6 | - Next >



Learn more about SharePoint



Sponsor Information




Copyright (c) 2010-2017 Edgewood Solutions, LLC All rights reserved
privacy | disclaimer | copyright | advertise | contribute | feedback | about
Some names and products listed are the registered trademarks of their respective owners.


MSSharePointTips.com | MSSQLTips.com