Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

custom role, access for right users

$
0
0

Hi,

I am creating portal which contains three folders: Accounting, Production and Stock. These folders contain own files. I made own membership which working ok. In database I have table “Users” for user  authentication with following columns: user_id, username, password, department. I would like that user will be directed to file in right folder after logging (I think it will not be problem) and have not any access to remaining folders (that is problem). 

Below is part of code for login

protected void button1_Click(object sender, EventArgs e)
        {
            int s = 0;
            string h = "";
            string stat = "";
            string department = "";


            if (checkBox1.Checked)
            { stat = "t"; }
            else { stat = "f"; }

            CustomMembershipProvider cmp = (CustomMembershipProvider)Membership.Providers["CustomMembershipProvider"];
            cmp.logowanie(textBox1.Text, textBox2.Text, out s, out h, out department);

            string nazwa = textBox1.Text;

            switch (s)
            {
                case 0:
                    Response.Redirect("Zmiana_Hasla.aspx?login="+nazwa+"&stat="+stat);
                    break;
                case 1:
                    FormsAuthentication.RedirectFromLoginPage(textBox1.Text, checkBox1.Checked);
                    break;
                case 2:
                    label1.Text = "Konto zablokowane";
                    break;
                case 3:
                    label1.Text = "Błędne hasło użytkownika";
                    break;
                case 4:
                    label1.Text = "Brak użytkownika w bazie";
                    break;
                case 5:
                    label1.Text = "Konto nieaktywne. Aktywuj najpierw konto.";
                    break;
            }
        }

How to keep or declare “department” as role and then declare access in web.config or other? Is it possible? Maybe someone has another idea? 

Thank you in advance for any responses and ideas.

Regards

Krzysztof


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>