private void GetPrincipal() { try { DateTime currentTime = DateTime.Now; HttpCookie cookie; cookie = HttpContext.Current.Request.Cookies[GlobalStatics.CookieName]; #region If is local machine, use localuser if (HttpContext.Current.Request.IsLocal) { bool[] m1 = new bool[32]; bool[] m2 = new bool[32]; for (int i = 0; i < m1.Length; i++) { m1[i] = true; m2[i] = true; } _APIUserPrincipal = new APIPrincipal(LocalUserId, LocalUserLoginEmail, m1, m2); HttpContext.Current.User = _APIUserPrincipal; UserManager userManager = new UserManager(); _User = userManager.GetUserbyId(ConfigurationManager.AppSettings["LocalUserId"]); _User.Roles = new UserManager().GetUserRoles(ConfigurationManager.AppSettings["LocalUserId"]); this.SavePrin(_APIUserPrincipal); this.CheckPermittedRole(); //this.CheckEnvironment(); return; } #endregion disable EdgarAuth for special needs //Log.Debug(cookie); GlobalStatics.MonitorProcessTime("First log", ref currentTime, DateTime.Now); if (cookie != null) { _User = GetUserFromCookie(); if (_User != null) { this.CheckPermittedRole(); //this.CheckEnvironment(); } else { this.GoToLogin(); //Log.Error("Failed to get auth info from cookie."); } } else { this.GoToLogin(); } GlobalStatics.MonitorProcessTime("EndAuthenticate", ref currentTime, DateTime.Now); } catch (Exception ex) { //Log.Error(ex); throw ex; } }