Click here to Skip to main content
12,998,759 members (69,279 online)
Rate this:
Please Sign up or sign in to vote.
See more:
In my sql db I have permissions to allow users access to different web pages in my app. I have a page where i can dynamically change the permissions of the users during runtime. Can I allow/deny user access without using web.config?
Here's my code so far in a class:
public static int AllowUserAccess(int agentID, string formName)
            SqlDataReader reader;
            int userid = 0;
                conn = OpenConnection();
                comm = new SqlCommand();
                comm.Connection = conn;
                comm.CommandType = CommandType.Text;
                comm.CommandText = "Select a.pkAgentID, PERM.FormName, AGP.fkAgentGroupID, agp.AllowAccess from Agents A inner join AgentGroupPermissions AGP on a.fkAgentGroupID = agp.fkAgentGroupID inner join Permission Perm ON AGP.fkPermissionID = PERM.pkPermissionID WHERE A.pkAgentID = @AgentID AND PERM.FormName = @FormName";
                comm.Parameters.Add("@AgentID", SqlDbType.Int).Value = agentID;
                comm.Parameters.Add("@FormName", SqlDbType.VarChar).Value = formName;

                reader = comm.ExecuteReader();
                if (reader.IsClosed == false)
                return userid;
            catch (Exception ex)
                return userid;

In my site.master i wish to get this function and use it to authorize certain permissions once the user logs in. This is what I have so far:
protected void AllowAccess()
           SqlCommand comm = new SqlCommand();
           string id = Request.Params["AgentID"];
           int agentID = Convert.ToInt32(id);
           string form = "";
           int access = DataFunctions.AllowUserAccess(agentID, form);
           bool allow = false;
           if (allow == true)

I'm stuck and I do not know what else to do in regards of getting the AllowAccess value and then getting a path or to show the specific web pages for each particular user.
Posted 26-Nov-12 1:15am
Updated 26-Nov-12 1:20am
ryanb31 26-Nov-12 8:49am
What's the issue? It looks like you have code to validate whether or not they can access a page. What's wrong?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

change your permissions with Ajax ; first make a page that can change permissions when you send a quarry string then send id in client side to that page ...
hope help full

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170622.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100