Return to Snippet

Revision: 38480
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") 

    // 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 = 
    SPRoleDefinitionCollection siteRoleCollection = 
    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. 

Initial URL

Initial Description

Initial Title
Check if user has a specific Role Definition

Initial Tags
security, sharepoint

Initial Language