// // GET: /Home/ public ActionResult Index() { User user = new User(); // Permission groups declared in Web.config Dictionary <String, int> permGroups = new Dictionary <String, int>() { { "RoomPermissions", 1 }, { "FullPermissions", 2 } }; // Date and time ViewBag.CurrentTime = DateTime.Now.ToString("F"); // Catch WindowsPrincipal errors if (user.getUserPrincipal() == null) { ViewBag.userAuth = "ERROR: UserPrincipal is null"; } else if (user.getUserPrincipal().Identity == null) { ViewBag.userAuth = "ERROR: Identity is null"; } else if (!user.getUserPrincipal().Identity.IsAuthenticated) { ViewBag.userAuth = "ERROR: User not authenticated"; } else { ViewBag.userAuth = "Logged in as " + user.getUsername(); foreach (KeyValuePair <String, int> permGroup in permGroups) { user.setPermissions(permGroup.Key, permGroup.Value); } // FOR DEVELOPMENT -- Full user/impersonation check ViewBag.LogonUID = System.Web.HttpContext.Current.Request.LogonUserIdentity.Name.ToString(); ViewBag.IsAuth = System.Web.HttpContext.Current.Request.IsAuthenticated.ToString(); ViewBag.IDName = System.Web.HttpContext.Current.User.Identity.Name.ToString(); ViewBag.EnvUN = System.Environment.UserName.ToString(); // FOR DEVELOPMENT -- Impersonated user ViewBag.WinIDCurName = System.Security.Principal.WindowsIdentity.GetCurrent().Name; // FOR DEVELOPMENT -- Store all groups for display //ViewBag.UserGroups = userGroups.ToArray(); // FOR DEVELOPMENT -- PC Name ViewBag.PCName = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.ToUpper(); // If authorized, give link to Control page; otherwise, link redirects to Index if (user.getUserAuthLevel() > 0) { ViewBag.Destination = "Control"; } else { ViewBag.Destination = "Index"; } } // Obtain client PC name string pcName; string pcDomainName = ".PCTI.TEC.NJ.US"; string fullPcName = System.Net.Dns.GetHostEntry(Request.ServerVariables["remote_addr"]).HostName.ToUpper(); if (fullPcName.Contains(pcDomainName)) { pcName = fullPcName.Remove(fullPcName.IndexOf(pcDomainName), pcDomainName.Length); } else { pcName = fullPcName; } ViewBag.pcName = pcName; // Get all Projector IPs from XML list in App_Data Projector projectorList = new Projector(pcName); ViewBag.deviceIp = projectorList.GetProjectorList(user.getUserAuthLevel()); return(View()); }