Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3481586
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:27:52+00:00 2026-05-18T10:27:52+00:00

I have 2 arraylists. One is principleList which contains integer values that denotes roles

  • 0

I have 2 arraylists. One is principleList which contains integer values that denotes roles (Admin, Project Manager etc.). Second is codeList which contains the various codes (e.g. AddUserProfile) for which I want to get permissions. I have a stored procedure “AllowedToPerformFunction” that returns allowed =0 or 1 depending on if a role can perform a code.

I am having trouble with the logic for this since I have multiple ids and multiple codes. For each id, I need to call the stored procedure with each code and store this.
I am trying to store permissions in a hashtable for various roles such as Admin, Project Manager. So for example for Admin i would need to store:

Admin (id =1)
code = “AddUser”,allowed =1
code=”AddProject”,allowed=0

hashtable format (key,value) = (1, AddUser-1), (1, AddProject-0)

Here is my code that isn’t working:

protected void Page_Load(object sender, EventArgs e)
{
    getPermissions();
}

void getPermissions()
{
  using (SqlConnection conn = new SqlConnection("GoalFishConnectionString")){conn.Open();

    ArrayList idList = getPrincipleIds();
    ArrayList codeList = getCodes();
    ArrayList allowList = new ArrayList();

    for (int i = 0; i < idList.Count; i++)
    {
        MessageBox.Show(idList[i].ToString());

        for (int j = 0; j < codeList.Count; j++)
        {


            MessageBox.Show(codeList[j].ToString());

            SqlCommand command2 = new SqlCommand("AllowedToPerformFunction", conn);
            command2.CommandType = CommandType.StoredProcedure;
            command2.Parameters.Clear();
            command2.Parameters.Add("@principalID", SqlDbType.Int).Value = idList[i];
            command2.Parameters.Add("@contextID", SqlDbType.Int).Value = idList[i];
            command2.Parameters.Add("@roleCode", SqlDbType.VarChar).Value = codeList[j];
            command2.Parameters.Add("@allowed", SqlDbType.Int);
            command2.Parameters["@allowed"].Direction = ParameterDirection.Output;
            command2.ExecuteNonQuery();

            int allowed = (int)command2.Parameters["@allowed"].Value;                
            allowList.Add(command2.Parameters["@allowed"].Value);
        }
    }}}

ArrayList getPrincipleIds()
{
    ArrayList principleList = new ArrayList();
         using (SqlConnection conn = new SqlConnection("GoalFishConnectionString")){
        conn.Open();
        SqlCommand cmd = new SqlCommand("GetPrinciples", conn);
        cmd.CommandType = CommandType.StoredProcedure;
        SqlDataReader rdr = cmd.ExecuteReader();

        while (rdr.Read())
        {
            principleList.Add(rdr["unit_id"]);
        }

        rdr.Close();

  }

    return principleList;
}

ArrayList getCodes()
{
    ArrayList codesList = new ArrayList();
   using (SqlConnection conn = new SqlConnection("GoalFishConnectionString")){
        conn.Open();

        SqlCommand command = new SqlCommand("GetCodes", conn);
        command.CommandType = CommandType.StoredProcedure;
        SqlDataReader reader = command.ExecuteReader();

        while (reader.Read())
        {
            codesList.Add(reader["Code"]);
            //MessageBox.Show(reader["Code"].ToString());
        }

        reader.Close();
    }
   }

    return codesList;
}

Any advice or help with this would greatly be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:27:52+00:00Added an answer on May 18, 2026 at 10:27 am

    Why not make a class like this and store it in the session? This way you only have to worry about permissions for one user (unless a user can be admin & Project Manager at the same time)

    public class LoginUser
    {
        public loginUser
        {
            this.Permission = LoadAllPermissions()
        }
    
        public string Role { get; set; }
        public Dictionary<integer, string> Permission { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arraylists. One contains filenames and the other contains failurecount. These values
I have two arraylists that contains links in one and the root url in
I have a class that contains two arraylists which I'm trying to store objects
I have an AjaxFallbackDefaultDataTable which contains one row per test result. A test result
I have an arraylist that contains items called Room. Each Room has a roomtype
I have a collection of custom entity objects one property of which is an
I have a project that adds elements to an AutoCad drawing. I noticed that
I have a script that appends some rows to a table. One of the
I have a login.jsp page which contains a login form. Once logged in the
I need to make an ArrayList of ArrayLists thread safe. I also cannot have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.