Revision: 38480
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 4, 2011 00:52 by scholli
Initial Code
using (SPWeb site = this.Web)
{
// Validate the page request to avoid
// any malicious posts.
if (Request.HttpMethod == "POST")
SPUtility.ValidateFormDigest();
// Get a reference to the roles that
// are bound to the user and the role
// definition against which we need to
// verify the user.
SPRoleDefinitionBindingCollection usersRoles =
site.AllRolesForCurrentUser;
SPRoleDefinitionCollection siteRoleCollection =
site.RoleDefinitions;
SPRoleDefinition roleDefinition =
siteRoleCollection["Full Control"];
// Determine whether the user is in the role. If
// not, redirect the user to the access-denied page
if (usersRoles.Contains(roleDefinition))
{
//************************************
// Check whether post back to run
// code that initiates the page.
if (IsPostBack == true)
{
// Execute application page logic.
}
}
else
{
Response.Redirect("/_layouts/accessdenied.aspx");
}
}
Initial URL
http://msdn.microsoft.com/en-us/library/dd878359(v=office.12).aspx
Initial Description
Initial Title
Check if user has a specific Role Definition
Initial Tags
security, sharepoint
Initial Language
C#