Nishand's Blog

Welcome to my personal blog, All the information in this bogs is my ideas,findings and thoughts on .Net, Asp.Net and SharePoint.
ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND

How to set user permissions programmatically?

   1: SPSite site = null;
   2: SPWeb web = null;
   3: site = new SPSite("http://server:100/sites/DevSite/");
   4: web = site.OpenWeb();
   5: SPRoleAssignment roleAssignment = new SPRoleAssignment("domain\\user","alias@domain.com","Nishand","Simple Test For You!");
   6: SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Contributor);
   7: roleAssignment.RoleDefinitionBindings.Add(roleDefinition);
   8: web.RoleAssignments.Add(roleAssignment); 

 

Enjoy!!!

Published Thursday, May 24, 2007 12:19 AM by nishandv

Comments

No Comments
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker