Esempio n. 1
0
        public ActionResult LoginPage(FormCollection collection)
        {
            try
            {
                ActiveDirectoryClient client = new ActiveDirectoryClient();

                string vunetId     = collection["Username"];
                string ePass       = collection["Password"];
                string name        = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                bool   isValidUser = client.ValidateVUnetIDePassword(vunetId, ePass);
                if (isValidUser)
                {
                    ApplicationSecurityClient securityClient = new ApplicationSecurityClient();
                    List <UserDTO>            users          = new List <UserDTO>();
                    using (securityClient)
                    {
                        users = securityClient.GetAllUsersInApplication("DTM").ToList();

                        if (!string.IsNullOrEmpty(users.Where(x => x.IsActive == true && x.VunetId == vunetId).Select(x => x.VunetId).FirstOrDefault()))
                        {
                            System.Web.Security.FormsAuthentication.SetAuthCookie(vunetId, true);
                            HttpContext.Session.Timeout = 90;
                            return(RedirectToAction("ShowExistingRequests", "ExistingRequests"));
                        }
                        else
                        {
                            return(View("Unauthorized"));
                        }
                    }
                }
                else
                {
                    return(View("Unauthorized"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("ErrorLanding", "Login"));
            }
        }