I think permissions are complicated. I wrote a simple code that reads the permission list of this user after logging on and put it in a hashtable, put it in a session and compare whether the menu or File Permission is in hashtable. I don't know if this idea is true or not. I hope you will give your comments.
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Public partial class default5: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
}
Protected void button#click (Object sender, eventargs E)
{// Indicates whether to log on
Session ["username"] = "admin ";
Hashtable ht = new hashtable ();
Ht. Add ("survey management", "1 ");
Ht. Add ("news management", "2 ");
Ht. Add ("member management", "3 ");
// Permission table
Session ["Popedom"] = HT;
}
Protected void button2_click (Object sender, eventargs E)
{
Session. Abandon ();
}
Protected void linkbutton#click (Object sender, eventargs E)
{
If (session ["username"]! = NULL)
{
If (hashtable) session ["Popedom"]). Contains ("Investigation Management "))
{
Linkbutton1.text = "Investigation Management permission ";
}
}
Else
{
Linkbutton1.text = "you do not have the investigation management permission ";
Page. clientscript. registerclientscriptblock (page. GetType (), "DD", "alert ('You have no investigation management authorization');", true );
}
}
Protected void linkbutton2_click (Object sender, eventargs E)
{
If (session ["username"]! = NULL)
{
If (hashtable) session ["Popedom"]). Contains ("news management "))
{
Linkbutton2.text = "news management permission ";
}
}
Else
{
Linkbutton2.text = "You are not authorized to manage News ";
Page. clientscript. registerclientscriptblock (page. GetType (), "DD", "alert ('You have no news managementauthorization');", true );
}
}
}