Home > SharePoint Development > Add/Provide permission to user at site programatically

Add/Provide permission to user at site programatically

1. Process to provide  Full control to user at site

SPUser oUser=web.AllUsers[“domain/username”];

SPRole admins = web.Roles[“Full Control”];
admins.AddUser(oUser.LoginName, oUser.Email, siteRequestor.User.Name, “Notes”);

Or
web.AssociatedOwnerGroup.AddUser(oUser);

Or

SPRoleDefinition roleDefination;
SPRoleAssignment roleAssignment;

roleDefination = web.RoleDefinitions[“Full Control”];
roleAssignment = new SPRoleAssignment(oUser);
roleAssignment.RoleDefinitionBindings.Add(roleDefination);
web.RoleAssignments.Add(roleAssignment);

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: