Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            m_AwHelpers = new AwareHelpers(m_AppSettings.GetAwareDbConnectionString);
            if (true == string.IsNullOrEmpty((string)Session["UserSid"]))
            {
                Session["LastError"] = "NO_ERROR";
                Response.Redirect("Logon.aspx");
            }
            else
            {
                if (false == IsPostBack)
                {
                    lblLoggedOnUser.Text = string.Format("Logged on user: {0} : ", _TranslateUserSidToName((string)Session["UserSid"]));
                    _InitReportsList();
                    _HideAllParamPanels();
                    _SetCalDates();
                    TbAlertStartDate.Text = DateTime.Now.AddDays(m_AppSettings.GetDefaultDateSpan).ToShortDateString();
                    TbAlertEndDate.Text   = DateTime.Now.ToShortDateString();
                    CompareValidatorTextBoxStartDate.ValueToCompare = DateTime.Now.ToShortDateString();
                    CompareValidatorTextBoxEndDate.ValueToCompare   = DateTime.Now.ToShortDateString();
                    if (Session["IsSuperUser"].ToString() == "True")
                    {
                        LkBtnAdminTools.Visible = true;
                    }
                    else
                    {
                        LkBtnAdminTools.Visible = false;
                    }

                    if (Session["IsVistaLogon"] == "True")
                    {
                        // get the provider id from the provider table
                        Guid tmp = Guid.Parse(Session["UserSid"].ToString());
                    }

                    // get the last update time
                    string lastUpdate = _GetLastUpdateTimeDate();
                    if (true == string.IsNullOrWhiteSpace(lastUpdate))
                    {
                        lblLastUpdated.Visible = false;
                    }
                    else
                    {
                        lblLastUpdated.Visible = true;
                        lblLastUpdated.Text    = string.Format("Last Update: {0}", lastUpdate);
                    }
                }
            }
            m_AppSettings.ApplBaseUrl = GetApplicationBaseUrl();

            btnViewReport.Enabled = (ddlistReports.SelectedIndex > 0);

            if (true == IsPostBack)
            {
                _EnsureRequiredIsRed();
            }
        }
Пример #2
0
        private bool ValidateAVCodes()
        {
            bool isValid = false;
            HAR_StringEncrypter encrypter   = new HAR_StringEncrypter();
            AwareAppSettings    appSettings = new AwareAppSettings();
            AwareHelpers        awHelpers   = new AwareHelpers(appSettings.GetAwareDbConnectionString);

            if (true == awHelpers.AwareSecurity.VerifyUserCredentials(tboxUserName.Text, encrypter.EncryptString(tboxPassword.Text)))
            {
                isValid = true;
            }

            return(isValid);
        }
Пример #3
0
        private bool ValidateGroupMembership()
        {
            bool validated = false;
            List <GroupPrincipal> grpMemberships = new List <GroupPrincipal>();

            grpMemberships = GetUserGroups(tboxUserName.Text);
            AwareAppSettings appSettings = new AwareAppSettings();
            AwareHelpers     awHelpers   = new AwareHelpers(appSettings.GetAwareDbConnectionString);

            foreach (GroupPrincipal grp in grpMemberships)
            {
                awHelpers.AwareSecurity.IsGroupPermittedAccess(grp.Name);
            }

            return(validated);
        }
Пример #4
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            lblLogonStatus.Text    = "Attempting to logon...";
            Session["IsSuperUser"] = ValidateSUlogon().ToString();
            _awareHelpers          = new AwareHelpers(_appSettings.GetAwareDbConnectionString);
            try
            {
                if (true == _AuthenticateUser(tboxUserName.Text.Substring(0, tboxUserName.Text.IndexOf('\\')), tboxUserName.Text.Substring((tboxUserName.Text.IndexOf('\\') + 1)), tboxPassword.Text))
                {
                    if (true == ValidateSUlogon())
                    {
                        Session["UserSid"]     = _TranslateUserNameToSid(tboxUserName.Text);
                        Session["LastError"]   = string.Empty;
                        Session["IsSuperUser"] = ValidateSUlogon().ToString();
                        Response.Redirect("Default.aspx");
                    }
                }
                else
                {
                    if (false == ValidateAVCodes())
                    {
                        Session["LastError"] = "Logon credentials were invalid";
                        Page_Load(sender, e);
                    }
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
                if (false == ValidateAVCodes())
                {
                    string svrResponse = string.Empty;
                    using (AwareQIManager.AwareWebSrv.WSAWARE webSrv = new WSAWARE())
                    {
                        webSrv.UseDefaultCredentials = true;
                        svrResponse = webSrv.Login(tboxUserName.Text, tboxPassword.Text);
                        if (null != webSrv)
                        {
                            webSrv.Dispose();
                        }
                    }

                    // comment the following 2 lines out when building for release
                    //svrResponse = "1^OCONNOR,CATHERINE C[53902]^53902"; //no see all
                    //svrResponse = "2^OCONNOR,CATHERINE C[53902]^53902"; // see all

                    if (0 < svrResponse.IndexOf(WS_LOGON_INVALID_PAIR))
                    {
                        Session["LastError"] = WS_LOGON_INVALID_PAIR;
                        Page_Load(sender, e);
                        return;
                    }
                    string[] tokens = svrResponse.Split('^');

                    Guid prvId = new Guid();
                    if (false == _awareHelpers.AwareSecurity.DoesProviderExist(tokens[2]))
                    {
                        if (true == _awareHelpers.VistaGroups.DoesVistaGroupExist(tokens[0]))
                        {
                            prvId = _awareHelpers.AwareSecurity.AddProvider(tokens[1], tokens[2], _awareHelpers.VistaGroups.GetVistaGroupId(tokens[0]));
                            Session["UserSid"]      = prvId.ToString();
                            Session["IsVistaLogon"] = "True";
                        }
                    }
                    else
                    {
                        prvId = _awareHelpers.AwareSecurity.UpdateProvider(tokens[1], tokens[2], _awareHelpers.VistaGroups.GetVistaGroupId(tokens[0]));
                        Session["UserSid"]      = prvId.ToString();
                        Session["IsVistaLogon"] = "True";
                    }

                    if (true == _awareHelpers.VistaGroups.DoesVistaGroupExist(tokens[0]))
                    {
                        Guid vistaGrp = _awareHelpers.VistaGroups.GetVistaGroupId(tokens[0]);
                        Session["VistaAccessKey"] = tboxUserName.Text;
                        Session["VistaGrpId"]     = (Guid)vistaGrp;
                        Session["LastError"]      = string.Empty;
                        Session["IsSuperUser"]    = ValidateSUlogon().ToString();
                        Response.Redirect("Default.aspx");
                    }
                    else
                    {
                        Session["LastError"] = "Logon credentials were invalid";
                        Page_Load(sender, e);
                    }
                }
                else
                {
                    Guid userId = new Guid();

                    userId = _awareHelpers.AwareUsers.GetUsersId(tboxUserName.Text);
                    if (userId != new Guid())
                    {
                        Session["UserSid"]     = userId.ToString();
                        Session["LastError"]   = string.Empty;
                        Session["IsSuperUser"] = ValidateSUlogon().ToString();
                        Response.Redirect("Default.aspx");
                    }
                    else
                    {
                        Session["LastError"] = "Logon credentials were invalid";
                        Page_Load(sender, e);
                    }
                }
            }
        }
Пример #5
0
 public Admin()
 {
     m_AwHelpers = new AwareHelpers(m_AppSettings.GetAwareDbConnectionString);
 }