void btnEdit_Click(object sender, EventArgs e) { HttpContext httpContext = HttpContext.Current; Facade.ISecurity facSecurity = new Facade.Security(); Facade.IUser facUser = new Facade.User(); string[] userRoleString = (((Entities.CustomPrincipal)httpContext.User).UserRole.Split(new char[] { ',' })); eUserRole[] userRole = new eUserRole[userRoleString.Length]; for (int i = 0; i < userRoleString.Length; i++) { userRole[i] = (eUserRole)int.Parse(userRoleString[i]); } bool canEdit = false; foreach (eUserRole r in userRole) { if (r == eUserRole.SystemAdministrator) { canEdit = true; } } if (canEdit) { NotesEditor.EditModes = Telerik.Web.UI.EditModes.All; } else { NotesEditor.EditModes = Telerik.Web.UI.EditModes.Preview; } }
public static bool CanAccess(params eSystemPortion[] systemPortions) { bool canAccess = false; HttpContext httpContext = HttpContext.Current; Facade.ISecurity facSecurity = new Facade.Security(); Facade.IUser facUser = new Facade.User(); string[] userRoleString = (((Entities.CustomPrincipal)httpContext.User).UserRole.Split(new char[] { ',' })); eUserRole[] userRole = new eUserRole[userRoleString.Length]; for (int i = 0; i < userRoleString.Length; i++) { userRole[i] = (eUserRole)int.Parse(userRoleString[i]); } // Store this user's roles and the portions testing against in the session. httpContext.Session["UserRole"] = userRole; httpContext.Session["SystemPortions"] = systemPortions; foreach (eSystemPortion sp in systemPortions) { if (facSecurity.CanAccessPortion(userRole, sp)) { canAccess = true; break; } } return(canAccess); }
protected string path = "releaseNotes.html"; //specify the path to your file protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //set the external file content in the editor NotesEditor.Content = ReadFile(Server.MapPath(path)); NotesEditor.EditModes = Telerik.Web.UI.EditModes.Preview; } HttpContext httpContext = HttpContext.Current; Facade.ISecurity facSecurity = new Facade.Security(); Facade.IUser facUser = new Facade.User(); string[] userRoleString = (((Entities.CustomPrincipal)httpContext.User).UserRole.Split(new char[] { ',' })); eUserRole[] userRole = new eUserRole[userRoleString.Length]; for (int i = 0; i < userRoleString.Length; i++) { userRole[i] = (eUserRole)int.Parse(userRoleString[i]); } bool canEdit = false; foreach (eUserRole r in userRole) { if (r == eUserRole.SystemAdministrator) { canEdit = true; } } if (!canEdit) { Server.Transfer("relnotes.aspx"); } pnldmin.Visible = canEdit; }