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

Giving User Access On Menu by Menu Page by Page

$
0
0

Access is granted on a menu by menu and a page by page basis
Currently it is set-up so that a stored procedure is run to check the logged-in users permission to the menu's and pages
if the procedure returns true then access is granted and the menu/page is visible
if the procedure returns false then access is denied and the menu/page is invisible
Very lengthy and time consuming. Code structure is currently set-up like such, is their a way to speed up this process and still have authorization set-up on a menu by menu page by page set-up?

public class HasPermissions
{
	private bool menuStoreInfo = false;
    private bool Store1Data = false;
    private bool Store2Data = false;
	private bool Store1Schedule = false;
	private bool Store2Schedule = false;
	private bool Store1VacCalendar = false;
	private bool Store2VacCalendar = false;
	private bool Store1VacRequest = false;
	private bool Store2VacRequest = false;
	private bool menuStoreAdminInfo = false;
	//and many many more
   public HasPermissions GetEmployeePermissions(string databaseConnection, int userID)
   {
		DataSet _dataSet = new DataSet();
		//Run Procedure to get permissions

		if (_dataSet.Tables[0].Rows.Count > 0)
		{
			foreach (DataRow row in _dataSet.Tables[0].Rows)
			{
			    int authorizationID = row[authorizationID];
				switch (authorizationID)
				{
					case menuStoreInfo:
						if (accessGranted == 1)
						{
							menuStoreInfo = true;
						}
						else
						{
							menuStoreInfo = false;
						}
						break;
					case Store1Data:
						if (accessGranted == 1)
						{
							Store1Data = true;
						}
						else
						{
							Store1Data  =false;
						}
						break;
					//So on and so on
			}
		}   
		return new UserPermissions();
   }
}


Viewing all articles
Browse latest Browse all 4737

Trending Articles