Click here to Skip to main content
15,884,099 members
Articles / Web Development / ASP.NET

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

Rate me:
Please Sign up or sign in to vote.
4.80/5 (18 votes)
11 Nov 2011Ms-PL5 min read 107.7K   9.3K   74  
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.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="install.aspx.cs" Inherits="install_install" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <table class="style1">
            <tr>
                <td colspan="2">
                    Hi, The database for the application has not been installed yet. Below is 
                    information regarding installation of Database to Mysql. The sql script for 
                    other databaes is needed to be ported yet.<br />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Literal ID="lblMessage" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    Step 1 (Check Database Connection ):</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    Server Name</td>
                <td>
                    <asp:TextBox ID="txtDbSrvrName" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
&nbsp;Database Name to Check</td>
                <td>
                    <asp:TextBox ID="txtDbName" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                        ControlToValidate="txtDbName" ErrorMessage="*Please input database name."></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Database User Id</td>
                <td>
                    <asp:TextBox ID="txtDbUserId" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Database Password</td>
                <td>
                    <asp:TextBox ID="txtDbPass" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Database Type</td>
                <td>
                    <asp:DropDownList ID="drpDbType" runat="server">
                        <asp:ListItem Value="-1">--Select--</asp:ListItem>
                        <asp:ListItem>Mysql</asp:ListItem>
                        <asp:ListItem Value="MSSql">Sql Server</asp:ListItem>
                        <asp:ListItem>Oracle</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Button ID="btnCreateDb" runat="server" onclick="btnCreateDb_Click" 
                        Text="Test" />
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    Nhibernate Connection String (From Web.Config):</td>
                <td>
                    <asp:Literal ID="lblConnStrName" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    Nhibernate Dialect (From Web.Config):</td>
                <td>
                    <asp:Literal ID="lblNHDialect" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    Step 2:</td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    Below&nbsp; is the Database script for the specified Database type. Click on the 
                    execute button to run the script.</td>
                <td>
                    <asp:Button ID="btnExecuteScript" runat="server" 
                        onclick="btnExecuteScript_Click" Text="Execute" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:Literal ID="lblDbScript" runat="server"></asp:Literal>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    &nbsp;</td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>

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)


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

Comments and Discussions