protected void Page_Load(object sender, EventArgs e) { SPWeb currentWeb = SPContext.Current.Web; if (currentWeb.Name.ToLower().Equals("policies") || currentWeb.ServerRelativeUrl.ToLower().Equals("/policies")) { return; } Page.Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); SPUser currentUser = currentWeb.CurrentUser; var currentPage = Request.CurrentExecutionFilePath; PermissionGroupDAL = new PermissionGroupDAL(SPContext.Current.Site.RootWeb.Url); var groups = new List <string>(); var items = currentWeb.CurrentUser.Groups.GetEnumerator(); while (items.MoveNext()) { groups.Add(items.Current.ToString()); } var hasPermission = PermissionGroupDAL.IsAuthorizedOnPage(SPContext.Current.Site.RootWeb, currentPage, groups); if (!hasPermission) { var ex = new SecurityException(); SPUtility.HandleAccessDenied(ex); } if (currentUser.IsSiteAdmin == false && UserPermission.IsCurrentUserInGroup(StringConstant.Group.CommonAccountGroupName) && HttpContext.Current.Session[StringConstant.EmployeeLogedin] == null) { string url = HttpContext.Current.Request.Url.AbsoluteUri; if (url.Contains(StringConstant.PageLoginURL) || url.Contains(StringConstant.PageHomeURL)) { return; } Response.Redirect(StringConstant.PageLoginURL); } }
private void InitialData(SPWeb spWeb) { var url = spWeb.Url; permissionGroupDAL = new PermissionGroupDAL(url); // Get groups of current user var groups = new List <string>(); var items = spWeb.CurrentUser.Groups.GetEnumerator(); while (items.MoveNext()) { groups.Add(items.Current.ToString()); } var permissionGroupList = permissionGroupDAL.GetPagesOnLeftMenu(groups).Where(x => x.PermissionModuleCategory != null); if (permissionGroupList != null && permissionGroupList.Count() > 0) { var groupPermissionGroupList = permissionGroupList.OrderBy(x => x.LeftMenuOrder).GroupBy(x => x.PermissionModuleCategory.LookupValue); BindingMenuView(spWeb, groupPermissionGroupList); } }