Click here to Skip to main content
11,566,785 members (49,881 online)
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
Add your own
alternative version

Extending ASP.NET role based Security with Custom Security Module (Permission Based, Page Level Authorization)

, 11 Nov 2011 Ms-PL 73.2K 8.2K 73
This project intends to extend the default ASP.NET role based Security to include Permission Based / Page Level Authorization Layer. Works with both ASP.NET and ASP.NET MVC. Permission rules to Allow/Deny access to website resources (like "Folder/File.aspx" or "Controller/Action") are stored in DB.
AadhaarMS.zip
AadhaarMS
Aadhaar.Data
bin
Debug
Aadhaar.Data.dll
Aadhaar.Data.MS.dll
Castle.Core.dll
Castle.DynamicProxy.dll
Castle.DynamicProxy2.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
NHibernate.JetDriver.dll
NHibernateProvider.dll
Entity
Components
Mapping
Helper
Properties
Util
ViewModel
Aadhaar.Web
Activities1
Activities2
App_Code
App_Data
AadhaarMS.MDF
AadhaarMS_log.ldf
Bin
Aadhaar.Data.dll
Aadhaar.Data.pdb
Castle.Core.dll
Castle.DynamicProxy.dll
Castle.DynamicProxy2.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
NHibernate.JetDriver.dll
NHibernateProvider.dll
Controls
css
Global.asax
images
hdrLogo.jpg
i-bb.gif
i-blc.gif
i-brc.gif
i-l.gif
i-r.gif
i-tb.gif
i-tlc.gif
i-trc.gif
img01.jpg
spacer.gif
install
logs
Superadmin
AadhaarMVC.zip
AadhaarMVC
Aadhaar.Data
bin
Debug
Aadhaar.Data.dll
Aadhaar.Data.MS.dll
Castle.Core.dll
Castle.DynamicProxy.dll
Castle.DynamicProxy2.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
NHibernate.JetDriver.dll
NHibernateProvider.dll
Entity
Components
Mapping
Helper
Properties
Util
ViewModel
Aadhaar.MVC
Aadhaar.MVC.csproj.user
App_Data
AadhaarMS.MDF
AadhaarMS_log.ldf
bin
Aadhaar.Data.dll
Aadhaar.Data.pdb
Aadhaar.MVC.dll
Aadhaar.MVC.pdb
Castle.Core.dll
Castle.DynamicProxy.dll
Castle.DynamicProxy2.dll
Iesi.Collections.dll
log4net.dll
NHibernate.dll
NHibernate.JetDriver.dll
NHibernateProvider.dll
Content
images
hdrLogo.jpg
i-bb.gif
i-blc.gif
i-brc.gif
i-l.gif
i-r.gif
i-tb.gif
i-tlc.gif
i-trc.gif
img01.jpg
spacer.gif
Controllers
Global.asax
Models
obj
Debug
Aadhaar.MVC.dll
Aadhaar.MVC.pdb
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
ResolveAssemblyReference.cache
TempPE
Properties
Scripts
Views
Account
Admin
Error
Home
Shared
Aadhaar.suo
using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class registration : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //if (!Page.IsPostBack)
        //{
        //    DropDownList ddnTZ = (DropDownList)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ddnTimeZone");
        //    ddnTZ.DataSource = TimeZoneInfo.GetSystemTimeZones();
        //    ddnTZ.DataValueField = "Id";
        //    ddnTZ.DataTextField = "DisplayName";
        //    ddnTZ.DataBind();
        //}
    }
    //protected void CreateUserExWizard1_CreatedUser(object sender, EventArgs e)
    //{
    //    if (Page.IsValid)
    //    {
    //        TextBox UserName = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
    //        TextBox Email = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email");
    //        TextBox Question = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Question");
    //        TextBox Answer = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Answer");
    //        TextBox Passwrd = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Password");

    //        TextBox Name = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Name");
    //        TextBox Surname = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Surname");
    //        TextBox Company = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Company");
    //        TextBox Phone = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Phone");
    //        TextBox PostalCode = (TextBox)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("PostalCode");
    //        DropDownList ddnTZ = (DropDownList)CreateUserExWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ddnTimeZone");

    //        try
    //        {
    //            // Attempt to register the user
    //            MembershipCreateStatus createStatus;
    //            MembershipUser currentUser = Membership.CreateUser(UserName.Text,Passwrd.Text, Email.Text,Question.Text,Answer.Text,true,null, out createStatus);

    //            if (createStatus == MembershipCreateStatus.Success)
    //            {
    //                setAuthCookie(currentUser);

    //               System.Web.Profile.ProfileBase prof = ProfileCommon.Create(UserName.Text, true);



    //               prof.SetPropertyValue("Name", Name.Text);
    //               prof.SetPropertyValue("Surname", Surname.Text);
    //               prof.SetPropertyValue("Company", Company.Text);
    //               prof.SetPropertyValue("Phone", Phone.Text);
    //               prof.SetPropertyValue("PostalCode", PostalCode.Text);
    //               prof.SetPropertyValue("TimeZone", ddnTZ.SelectedValue);

    //            }
    //            else
    //            {

    //                ((IErrorMessage)Master).SetError(GetType(), new Exception(ErrorCodeToString(createStatus)));

    //            }
    //        }
    //        catch (Exception exc)
    //        {

    //            ((IErrorMessage)Master).SetError(GetType(), exc);
    //        }

    //    }
    //}

    //#region private methods

    //private void setAuthCookie(MembershipUser currentUser)
    //{
    //    //Set Auth cookie
    //    //FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
    //    string userData = String.Empty;
    //    userData = userData + "Email=" + currentUser.Email;
    //    userData += ";UKeyN=" + currentUser.ProviderUserKey.ToString();
    //    userData += ";roleStr=" + string.Join(",", Roles.GetRolesForUser(currentUser.UserName));

    //    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, currentUser.UserName, DateTime.Now, DateTime.Now.AddMinutes(30), true, userData);
    //    string encTicket = FormsAuthentication.Encrypt(ticket);
    //    System.Web.HttpCookie faCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
    //    Response.Cookies.Add(faCookie);


    //}
    //#endregion

    //#region Status Codes
    //private static string ErrorCodeToString(MembershipCreateStatus createStatus)
    //{
    //    // See http://go.microsoft.com/fwlink/?LinkID=177550 for
    //    // a full list of status codes.
    //    switch (createStatus)
    //    {
    //        case MembershipCreateStatus.DuplicateUserName:
    //            return "User name already exists. Please enter a different user name.";

    //        case MembershipCreateStatus.DuplicateEmail:
    //            return "A user name for that e-mail address already exists. Please enter a different e-mail address.";

    //        case MembershipCreateStatus.InvalidPassword:
    //            return "The password provided is invalid. Please enter a valid password value.";

    //        case MembershipCreateStatus.InvalidEmail:
    //            return "The e-mail address provided is invalid. Please check the value and try again.";

    //        case MembershipCreateStatus.InvalidAnswer:
    //            return "The password retrieval answer provided is invalid. Please check the value and try again.";

    //        case MembershipCreateStatus.InvalidQuestion:
    //            return "The password retrieval question provided is invalid. Please check the value and try again.";

    //        case MembershipCreateStatus.InvalidUserName:
    //            return "The user name provided is invalid. Please check the value and try again.";

    //        case MembershipCreateStatus.ProviderError:
    //            return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

    //        case MembershipCreateStatus.UserRejected:
    //            return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.";

    //        default:
    //            return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator.";
    //    }
    //}
    //#endregion
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

amitthk
Software Developer (Senior)
Singapore Singapore
I love programming, reading, and meditation. I like to explore management and productivity.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150624.2 | Last Updated 12 Nov 2011
Article Copyright 2011 by amitthk
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid