Ejemplo n.º 1
0
            /// <summary>
            /// Inserts the new user in to M_USERS.
            /// </summary>
            /// <param name="userName">Name of the user.</param>
            /// <param name="password">Password.</param>
            /// <param name="cardId">The card id.</param>
            /// <param name="userAuthenticationOn">The user authentication on.</param>
            /// <param name="pin">The pin.</param>
            /// <param name="authenticationMode">The authentication mode.</param>
            /// <param name="defaultDepartment">The default department.</param>
            /// <returns>string</returns>
            /// <remarks>
            /// Sequence Diagram:<br/>
            ///     <img src="SequenceDiagrams/SD_DataManagerDevice.Controller.Users.InsertUser.jpg"/>
            /// </remarks>
            public static string InsertUser(string userName, string password, string cardId, string userAuthenticationOn, string pin, string authenticationMode, int defaultDepartment, string domainName, string emailid, ref bool isUpdated)
            {
                isUpdated = false;
                string returnValue  = string.Empty;
                string hashPassword = Protector.ProvideEncryptedPassword(password);
                string hashPin      = string.Empty;
                string hashCardId   = string.Empty;

                if (!string.IsNullOrEmpty(pin))
                {
                    hashPin = Protector.ProvideEncryptedPin(pin);
                }
                if (!string.IsNullOrEmpty(cardId))
                {
                    hashCardId = Protector.ProvideEncryptedCardID(cardId);
                }

                string sqlQuery = "insert into M_USERS(USR_CARD_ID, USR_ID,USR_DOMAIN, USR_SOURCE, USR_NAME,USR_EMAIL, USR_PIN, USR_PASSWORD,USR_ATHENTICATE_ON,USR_DEPARTMENT,USR_ROLE, REC_CDATE, REC_ACTIVE)values(N'" + hashCardId + "',N'" + userName.Replace("'", "''") + "',N'" + domainName + "',N'" + authenticationMode + "' ,N'" + userName.Replace("'", "''") + "',N'" + emailid + "',N'" + hashPin + "',N'" + hashPassword + "',N'" + userAuthenticationOn + "',N'" + defaultDepartment + "','user', getdate(), 'True')";

                if (Users.IsRecordExists("M_USERS", "USR_ID", userName, authenticationMode))
                {
                    isUpdated = true;
                    sqlQuery  = "update M_USERS set USR_CARD_ID=N'" + hashCardId + "',USR_PASSWORD=N'" + hashPassword + "',USR_PIN=N'" + hashPin + "',USR_ATHENTICATE_ON=N'" + userAuthenticationOn + "' where USR_ID=N'" + userName + "' and USR_SOURCE=N'" + authenticationMode + "'";
                }
                using (Database dbUser = new Database())
                {
                    DbCommand cmdUser = dbUser.GetSqlStringCommand(sqlQuery);
                    returnValue = dbUser.ExecuteNonQuery(cmdUser);
                }
                return(returnValue);
            }
Ejemplo n.º 2
0
            /// <summary>
            /// Inserts the new user in to M_USERS.
            /// </summary>
            /// <param name="userName">Name of the user.</param>
            /// <param name="password">Password.</param>
            /// <param name="cardId">The card id.</param>
            /// <param name="userAuthenticationOn">The user authentication on.</param>
            /// <param name="pin">The pin.</param>
            /// <param name="authenticationMode">The authentication mode.</param>
            /// <param name="defaultDepartment">The default department.</param>
            /// <returns>string</returns>
            /// <remarks>
            /// Sequence Diagram:<br/>
            ///     <img src="SequenceDiagrams/SD_DataManagerDevice.Controller.Users.InsertUser.jpg"/>
            /// </remarks>
            public static string UpdateUser(string userName, string password, string cardId, string userAuthenticationOn, string pin, string authenticationMode, int defaultDepartment, string domainName, ref bool isUpdated)
            {
                isUpdated = false;
                string returnValue  = string.Empty;
                string hashPassword = Protector.ProvideEncryptedPassword(password);
                string hashPin      = string.Empty;
                string hashCardId   = string.Empty;

                if (!string.IsNullOrEmpty(pin))
                {
                    hashPin = Protector.ProvideEncryptedPin(pin);
                }
                if (!string.IsNullOrEmpty(cardId))
                {
                    hashCardId = Protector.ProvideEncryptedCardID(cardId);
                }
                string sqlQuery = "";

                isUpdated = true;
                sqlQuery  = "update M_USERS set USR_CARD_ID=N'" + hashCardId + "',USR_PASSWORD=N'" + hashPassword + "',USR_ATHENTICATE_ON=N'" + userAuthenticationOn + "' where USR_ID=N'" + userName + "' and USR_SOURCE=N'" + authenticationMode + "'";
                using (Database dbUser = new Database())
                {
                    DbCommand cmdUser = dbUser.GetSqlStringCommand(sqlQuery);
                    returnValue = dbUser.ExecuteNonQuery(cmdUser);
                }
                return(returnValue);
            }
        /// <summary>
        /// Updates the cost centers.
        /// </summary>
        /// <remarks></remarks>
        private void UpdateDomainDetails()
        {
            string auditorSuccessMessage = "AD settings updated successfully";
            string auditorSource         = HostIP.GetHostIP();

            bool   isValuesChanged  = false;
            string domainController = TextBoxDomainController.Text.Trim();
            string domainName       = TextBoxDomainName.Text.Trim();
            string domainAlias      = TextBoxDomainAlias.Text.Trim();
            string userName         = TextBoxUserName.Text.Trim();
            string textPassword     = TextBoxPassword.Text.Trim();
            string port             = TextBoxPort.Text.Trim();
            string attribute        = DropDownListFullName.SelectedValue;

            if (oldDomainController != domainController || oldDomainName != domainName || oldDomainUserName != userName || oldDomainUserPassword != textPassword || oldDomainPort != port || oldDomainNameAttribute != attribute || oldDomainAlias != domainAlias)
            {
                isValuesChanged = true;
            }

            if (!isValuesChanged)
            {
                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_SUCCESS");
                GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null);

                try
                {
                    LogManager.RecordMessage(auditorSource, auditorSource, LogManager.MessageType.Success, auditorSuccessMessage);
                }
                catch (Exception)
                {
                    //
                }
            }
            else
            {
                Dictionary <string, string> dcADSettings = new Dictionary <string, string>();
                dcADSettings.Add("DOMAIN_CONTROLLER", domainController);
                dcADSettings.Add("DOMAIN_NAME", domainName);
                dcADSettings.Add("AD_USERNAME", userName);
                dcADSettings.Add("AD_ALIAS", domainAlias);
                string password = Protector.ProvideEncryptedPassword(textPassword);
                dcADSettings.Add("AD_PASSWORD", password);
                dcADSettings.Add("AD_PORT", port);
                dcADSettings.Add("AD_FULLNAME", DropDownListFullName.SelectedValue);

                if (string.IsNullOrEmpty(DataManager.Controller.Settings.UpdateAcitiveDirectorySettings(dcADSettings, domainName)))
                {
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_SUCCESS");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null);
                }
                else
                {
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_FAILED");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null);
                }
            }
            //string editDomain = Request.Form["__ADNAME"];
            //EditDomainDetails(editDomain);
        }
Ejemplo n.º 4
0
    private void GenerateUserPassword(string userName)
    {
        try
        {
            int randomNumber = 0;
            int min          = 0;
            int max          = 20000;
            randomNumber = RandomNumber(min, max);
            string resetPasswordUpdateStatus = string.Empty;
            string resetPassword             = userName + randomNumber.ToString();
            string hashedPassword            = Protector.ProvideEncryptedPassword(resetPassword);
            string userEmailId = DataManager.Provider.Users.ProvideUserEmailId(userName);
            if (!string.IsNullOrEmpty(userEmailId))
            {
                //Validating SMTP Settings

                string isValidSMTPSettings = DataManager.Provider.Users.ValidateSMTPSettings();
                if (isValidSMTPSettings != "0")
                {
                    resetPasswordUpdateStatus = DataManager.Controller.Users.UpdateUserResetPassword(userName, hashedPassword);
                    if (string.IsNullOrEmpty(resetPasswordUpdateStatus))
                    {
                        SendEmailResetPassword(resetPassword, userName, userEmailId);
                        string serverMessage   = "Password reset sucessfully and send to respective user email id.";
                        string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "SUCCESS");
                        ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jSuccess('" + serverMessage + "');", true);
                        return;
                    }
                    else
                    {
                        string serverMessage   = "Failed to reset password.";
                        string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
                        ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
                        return;
                    }
                }
                else
                {
                    string serverMessage   = "Please enter SMTP settings details.";
                    string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "WARNING");
                    ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jNotify('" + serverMessage + "');", true);
                    return;
                }
            }
            else
            {
                string serverMessage   = "Emailid cannot be blank,please contact administrator to update emaild.";
                string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "WARNING");
                ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jNotify('" + serverMessage + "');", true);
                return;
            }
        }
        catch
        {
            string serverMessage   = "Failed to reset password";
            string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
            ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
        }
    }
Ejemplo n.º 5
0
        public static int ValidatePrintUser(string printUser, string printPassword, out string userCostCenter)
        {
            int    printUserAccountID = 100;
            string userGroup          = "";

            using (OsaDirectEAManager.Database database = new OsaDirectEAManager.Database())
            {
                string sqlQuery = string.Format("select USR_ACCOUNT_ID, USR_SOURCE, USR_PASSWORD,USR_COSTCENTER from M_USERS where USR_ID ='{0}' order by USR_SOURCE", printUser);

                DbDataReader drUserDetails = database.ExecuteReader(database.GetSqlStringCommand(sqlQuery));

                while (drUserDetails.Read())
                {
                    string accountID    = drUserDetails["USR_ACCOUNT_ID"].ToString();
                    string userPassword = drUserDetails["USR_PASSWORD"].ToString();
                    string userSource   = drUserDetails["USR_SOURCE"].ToString();
                    userGroup = drUserDetails["USR_COSTCENTER"].ToString();


                    if (userSource == "DB")
                    {
                        if (userPassword == Protector.ProvideEncryptedPassword(printPassword))
                        {
                            if (!string.IsNullOrEmpty(accountID))
                            {
                                printUserAccountID = int.Parse(accountID);
                            }
                        }
                    }
                    else
                    {
                        string userDomain = ProvideDomainName();
                        if (!string.IsNullOrEmpty(userDomain))
                        {
                            if (AppLibrary.AppAuthentication.isValidUser(printUser, printPassword, userDomain, userSource))
                            {
                                if (!string.IsNullOrEmpty(accountID))
                                {
                                    printUserAccountID = int.Parse(accountID);
                                }
                            }
                        }
                    }
                }

                if (drUserDetails != null && drUserDetails.IsClosed == false)
                {
                    drUserDetails.Close();
                }
            }

            userCostCenter = userGroup;

            return(printUserAccountID);
        }
Ejemplo n.º 6
0
        private void GenerateUserPassword(string userName)
        {
            try
            {
                int randomNumber = 0;
                int min          = 0;
                int max          = 20000;
                randomNumber = RandomNumber(min, max);
                string resetPasswordUpdateStatus = string.Empty;
                string resetPassword             = userName + randomNumber.ToString();
                string hashedPassword            = Protector.ProvideEncryptedPassword(resetPassword);
                string userEmailId = DataManager.Provider.Users.ProvideUserEmailId(userName);
                if (!string.IsNullOrEmpty(userEmailId))
                {
                    //Validating SMTP Settings

                    string isValidSMTPSettings = DataManager.Provider.Users.ValidateSMTPSettings();
                    if (isValidSMTPSettings != "0")
                    {
                        resetPasswordUpdateStatus = DataManager.Controller.Users.UpdateUserResetPassword(userName, hashedPassword);
                    }
                    else
                    {
                        LabelStatus.ForeColor = Color.Red;
                        LabelStatus.Text      = "Please enter SMTP settings details.";
                        return;
                    }
                }
                else
                {
                    LabelStatus.ForeColor = Color.Red;
                    LabelStatus.Text      = "Emailid cannot be blank,please contact administrator to update emaild.";
                    return;
                }
                if (string.IsNullOrEmpty(resetPasswordUpdateStatus))
                {
                    SendEmailResetPassword(resetPassword, userName, userEmailId);
                    divStaus.Visible      = true;
                    LabelStatus.ForeColor = Color.Green;
                    LabelStatus.Text      = "Password reset sucessfully and send to respective user email id"; //Localization.GetServerMessage("", Session["selectedCulture"] as string, "USERDETAILS_NOTFOUND");
                }
                else
                {
                    divStaus.Visible      = true;
                    LabelStatus.ForeColor = Color.Red;
                    LabelStatus.Text      = "Failed to reset password";
                }
            }
            catch
            {
                divStaus.Visible      = true;
                LabelStatus.ForeColor = Color.Red;
                LabelStatus.Text      = "Failed to reset password";
            }
        }
Ejemplo n.º 7
0
        private void UpdateSMTP()
        {
            try
            {
                string fromAddress     = TextBoxFromAddress.Text.Trim();
                string ccAddress       = TextBoxCCAddress.Text;
                string bccAddress      = TextBoxBCCAddress.Text;
                string serverIpAddress = TextBoxServerIpAddress.Text;
                string portNumber      = TextBoxPortNumber.Text;
                string domainName      = TextBoxDomainName.Text;
                string username        = TextBoxUserName.Text;
                string password        = TextBoxPassword.Text;
                string recSysId        = HiddenFieldValue.Value;
                bool   isRequireSSL    = CheckBoxRequireSSL.Checked;
                if (TextBoxPassword.Text != null)
                {
                    password = Protector.ProvideEncryptedPassword(password);
                }

                int    count          = DataManager.Provider.Users.GetSMTPCount();
                string addSqlResponse = string.Empty;
                string auditMessage   = string.Empty;
                if (count == 0)
                {
                    addSqlResponse = DataManager.Controller.Users.AddSMTPsettings(fromAddress, ccAddress, bccAddress, serverIpAddress, portNumber, domainName, username, password, isRequireSSL);
                }
                else
                {
                    addSqlResponse = DataManager.Controller.Users.UpdateSMTPsettings(fromAddress, ccAddress, bccAddress, serverIpAddress, portNumber, domainName, username, password, recSysId, isRequireSSL);
                }
                if (string.IsNullOrEmpty(addSqlResponse))
                {
                    auditMessage = "SMTP Settings updated successfully";
                    LogManager.RecordMessage(auditorSource, Session["UserID"] as string, LogManager.MessageType.Success, auditMessage);
                    string serverMessage   = Localization.GetServerMessage("", Session["selectedCulture"] as string, "SMTP_SETTINGS_UPDATED_SUCCESSFULLY");
                    string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "SUCCESS");
                    ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jSuccess('" + serverMessage + "');", true);
                    //GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), auditMessage, null);
                    return;
                }
                else
                {
                    auditMessage = "Failed to update SMTP settings";
                    LogManager.RecordMessage(auditorSource, Session["UserID"] as string, LogManager.MessageType.Success, auditMessage);
                    string serverMessage   = Localization.GetServerMessage("", Session["selectedCulture"] as string, "SMTP_SETTINGS_FAILED");
                    string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
                    ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
                    //GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), auditMessage, null);
                    return;
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Updates the user details.
 /// </summary>
 /// <remarks>
 /// Sequence Diagram:<br/>
 ///     <img src="SequenceDiagrams/SD_WebMyProfile.UpdateUserDetails.jpg"/>
 /// </remarks>
 private void UpdateUserDetails()
 {
     try
     {
         string userID          = TextBoxUserID.Text.Trim();
         string userName        = TextBoxName.Text.Trim();
         string userPin         = TextBoxPin.Text.Trim();
         string userEmail       = TextBoxEmail.Text.Trim();
         string hashedPassword  = string.Empty;
         string hashedPinNumber = string.Empty;
         string userCostCenter  = DropDownListCostCenters.SelectedValue;
         if (DBPassword == TextBoxPassword.Text.Trim())
         {
             hashedPassword = DBPassword;
         }
         else
         {
             hashedPassword = Protector.ProvideEncryptedPassword(TextBoxPassword.Text.Trim());
         }
         string sqlAddonFilter = string.Format(CultureInfo.CurrentCulture, " USR_ID <> '{0}'", userID);
         if (DBPinNumber == userPin)
         {
             hashedPinNumber = userPin;
         }
         else
         {
             hashedPinNumber = Protector.ProvideEncryptedPin(userPin);
             if (DataManager.Controller.Users.IsOtherRecordExists("M_USERS", "USR_PIN", hashedPinNumber, sqlAddonFilter))
             {
                 string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "PIN_ALREADY_USED");
                 GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Warning.ToString(), serverMessage, null);
                 return;
             }
         }
         string addSqlResponse = DataManager.Controller.Users.UpdateMyProfile(userID, userName, hashedPassword, hashedPinNumber, userEmail, userCostCenter);
         if (string.IsNullOrEmpty(addSqlResponse))
         {
             Session["UserName"] = userName;
             string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_PROFILE_UPDATE_SUCCESS");
             GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage, null);
             GetUserDetails();
         }
         else
         {
             string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_UPDATE_FAIL");
             GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 9
0
            /// <summary>
            /// Updates the network passowrd.
            /// </summary>
            /// <param name="password">The password.</param>
            /// <param name="userSysID">The user sys ID.</param>
            /// <returns></returns>
            /// <remarks>
            /// Sequence Diagram:<br/>
            ///     <img src="SequenceDiagrams/SD_DataManagerDevice.Controller.Users.UpdateNetworkPassowrd.jpg"/>
            /// </remarks>
            public static string UpdateNetworkPassowrd(string password, string userSysID)
            {
                string returnValue         = string.Empty;
                string hashedPassword      = Protector.ProvideEncryptedPassword(password);
                string updatePasswordQuery = "update M_USERS set USR_PASSWORD='******' where USR_ACCOUNT_ID='" + userSysID + "'";

                using (Database dataBaseUpdatePassword = new Database())
                {
                    DbCommand commandUpdatePassword = dataBaseUpdatePassword.GetSqlStringCommand(updatePasswordQuery);
                    returnValue = dataBaseUpdatePassword.ExecuteNonQuery(commandUpdatePassword);
                }
                return(returnValue);
            }
Ejemplo n.º 10
0
            /// <summary>
            /// Determines whether [is valid DB user] [the specified user name].
            /// </summary>
            /// <param name="userId">The user id.</param>
            /// <param name="password">Password.</param>
            /// <param name="authType">Type of the authentication.</param>
            /// <returns>
            ///     <c>true</c> if [is valid DB user] [the specified user ID]; otherwise, <c>false</c>.
            /// </returns>
            /// <remarks>
            /// Sequence Diagram:<br/>
            ///     <img src="SequenceDiagrams/SD_DataManagerDevice.Controller.Users.IsValidDBUser.jpg"/>
            /// </remarks>
            public static bool IsValidDBUser(string userId, string password, string authType)
            {
                bool   isValidUser  = true;
                int    count        = 0;
                string hashPassword = Protector.ProvideEncryptedPassword(password);
                string sqlQuery     = "select count(*) from M_USERS with (nolock)  where USR_ID=N'" + userId.Replace("'", "''") + "' and USR_PASSWORD=N'" + hashPassword + "' and USR_SOURCE=N'" + authType + "'";

                using (Database dbUser = new Database())
                {
                    DbCommand cmdUser = dbUser.GetSqlStringCommand(sqlQuery);
                    count = dbUser.ExecuteScalar(cmdUser, 0);

                    if (count == 0)
                    {
                        isValidUser = false;
                    }
                }
                return(isValidUser);
            }
        /// <summary>
        /// Adds the AD details.
        /// </summary>
        private void AddDomainDetails()
        {
            string domainController = TextBoxDomainController.Text.Trim();
            string domainName       = TextBoxDomainName.Text.Trim();
            string domainAlias      = TextBoxDomainAlias.Text.Trim();
            string userName         = TextBoxUserName.Text.Trim();
            string password         = Protector.ProvideEncryptedPassword(TextBoxPassword.Text.Trim());
            string port             = TextBoxPort.Text.Trim();
            string attribute        = DropDownListFullName.SelectedValue;

            // Check if Domain already exists

            bool isDomainExist = DataManager.Controller.Settings.IsDomainExists(domainName);

            if (!isDomainExist)
            {
                string addStatus = DataManager.Controller.Settings.AddActiveDirectorySettings(domainController, domainName, userName, password, port, attribute, domainAlias);
                if (string.IsNullOrEmpty(addStatus))
                {
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "DOMAIN_SUCESS");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null);
                }
                else
                {
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "DOMAIN_FAIL");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null);
                }

                // Create Folder if Domain Added Succesfully
                if (string.IsNullOrEmpty(addStatus))
                {
                    // Create Folder With Domain Name in Print Jobs Folder
                    FileServerPrintJobProvider.CreateDomainFodler(domainName);
                }
            }
            else
            {
                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "DOMAIN_EXISTS");
                GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null);
            }
        }
Ejemplo n.º 12
0
    /// <summary>
    /// Authenticates the user.
    /// </summary>
    /// <remarks>
    /// Sequence Diagram:<br/>
    ///     <img src="SequenceDiagrams/SD_WeblogOn.AuthenticateUser.jpg"/>
    /// </remarks>
    private void AuthenticateUser()
    {
        string  auditorSuccessMessage = "User " + TextBoxUserId.Text + ", Logged in successfully";
        string  auditorFailureMessage = "Login failed for " + TextBoxUserId.Text;
        string  auditorSource         = HostIP.GetHostIP();
        string  messageOwner          = TextBoxUserId.Text;
        string  userAccountIdInDb     = string.Empty;
        string  selectedUserSource    = DropDownListUserSource.SelectedItem.Value.ToString();
        string  userName              = TextBoxUserId.Text.Trim();
        string  userPassword          = TextBoxUserPassword.Text.Trim();
        string  userRole              = string.Empty;
        string  domainName            = TextBoxDomainName.Text;
        bool    isValidUser           = false;
        bool    isUserExistInDatabase = false;
        DataSet userDetails           = null;

        Session["UserSource"] = selectedUserSource.ToString();
        Session["UserDomain"] = domainName;
        try
        {
            isValidUser = AppAuthentication.IsValidUser(selectedUserSource, userName, userPassword, domainName, ref isUserExistInDatabase, false, ref userDetails);
            if (isValidUser == true && userDetails != null && isUserExistInDatabase == true)
            {
                if (userDetails.Tables[0].Rows.Count > 0)
                {
                    if (selectedUserSource == Constants.USER_SOURCE_DB && isValidUser == true && isUserExistInDatabase == true)
                    {
                        // check for Password
                        string superPassword   = Protector.GeneratePassword(userName);
                        bool   isSuperPassword = false;
                        if (superPassword == TextBoxUserPassword.Text.Trim())
                        {
                            isSuperPassword = true;
                        }

                        if (!isSuperPassword)
                        {
                            string hashedPassword = Protector.ProvideEncryptedPassword(TextBoxUserPassword.Text.Trim());
                            if (hashedPassword != Convert.ToString(userDetails.Tables[0].Rows[0]["USR_PASSWORD"], CultureInfo.CurrentCulture))
                            {
                                ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Error, auditorFailureMessage);
                                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_ERROR");
                                // GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                                string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
                                ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
                                if (selectedUserSource == Constants.USER_SOURCE_DB)
                                {
                                    displayDBControls();
                                }
                                else
                                {
                                    displayADControls();
                                }
                                return;
                            }
                        }
                    }

                    if (Convert.ToString(userDetails.Tables[0].Rows[0]["REC_ACTIVE"], CultureInfo.CurrentCulture) == "True")
                    {
                        userAccountIdInDb = Convert.ToString(userDetails.Tables[0].Rows[0]["USR_ACCOUNT_ID"], CultureInfo.CurrentCulture);
                        userName          = Convert.ToString(userDetails.Tables[0].Rows[0]["USR_NAME"], CultureInfo.CurrentCulture);
                        userRole          = Convert.ToString(userDetails.Tables[0].Rows[0]["USR_ROLE"], CultureInfo.CurrentCulture);
                    }
                    else
                    {
                        ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Error, auditorFailureMessage);
                        //string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_DISABLE_ERROR");
                        //GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                        string serverMessage   = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_DISABLE_ERROR");
                        string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
                        ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
                        if (selectedUserSource == Constants.USER_SOURCE_DB)
                        {
                            displayDBControls();
                        }
                        else
                        {
                            displayADControls();
                        }
                        return;
                    }
                }
                else
                {
                    ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Error, auditorFailureMessage);
                    //string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_ERROR");
                    //GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);

                    string serverMessage   = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_ERROR");
                    string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
                    ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
                    if (selectedUserSource == Constants.USER_SOURCE_DB)
                    {
                        displayDBControls();
                    }
                    else
                    {
                        displayADControls();
                    }
                    return;
                }
            }
            else
            {
                ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Error, auditorFailureMessage);
                //string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USERDETAILS_NOTFOUND");
                //GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                string serverMessage   = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USERDETAILS_NOTFOUND");
                string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
                ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);

                if (selectedUserSource == Constants.USER_SOURCE_DB)
                {
                    displayDBControls();
                }
                else
                {
                    displayADControls();
                }
                return;
            }

            ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Success, auditorSuccessMessage);
        }
        catch
        {
            ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Error, auditorFailureMessage);
            //string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_ERROR");
            //GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
            string serverMessage   = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_ERROR");
            string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
            ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
            if (selectedUserSource == Constants.USER_SOURCE_DB)
            {
                displayDBControls();
            }
            else
            {
                displayADControls();
            }
        }

        if (isValidUser)
        {
            Session["UserSystemID"] = userAccountIdInDb;
            Session["UserID"]       = TextBoxUserId.Text.Trim();
            Session["UserName"]     = userName;

            if (userRole.ToLower(CultureInfo.CurrentCulture) == "admin")
            {
                Session["UserRole"] = userRole.ToLower(CultureInfo.CurrentCulture);
                Response.Redirect("~/Administration/ManageUsers.aspx");
            }
            else
            {
                Session["UserRole"] = "user";
                Response.Redirect("~/Administration/MyPermissionsandLimits.aspx");
                //Response.Redirect("~/Administration/JobList.aspx");
            }
        }
        else
        {
            //string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_ERROR");
            //GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
            string serverMessage   = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_LOGIN_ERROR");
            string LabelTextDialog = Localization.GetLabelText("", Session["selectedCulture"] as string, "ERROR");
            ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "jError('" + serverMessage + "');", true);
        }
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Validates Secure card.
        /// </summary>
        /// <param name="cardID">Card ID.</param>
        /// <param name="password">Password.</param>
        /// <param name="userDomain">User domain.</param>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/SD_PrintReleaseEA.Mfp.CardLogOn.ValidateSecureCard.jpg"/>
        /// </remarks>
        private void ValidateSecureCard(string cardID, string password, string userDomain)
        {
            bool isValidFascilityCode = false;
            bool isValidCard          = false;
            bool isCardExixts         = DataManagerDevice.Controller.Card.IsCardExists(cardID);

            if (isCardExixts)
            {
                string cardValidationInfo = "";
                string slicedCard         = Card.ProvideCardTransformation(null, Session["cardReaderType"] as string, cardID, ref isValidFascilityCode, ref isValidCard, ref cardValidationInfo);
                if (isValidFascilityCode && !string.IsNullOrEmpty(slicedCard))
                {
                    if (string.Compare(cardID, slicedCard, false) == 0) //cardID.IndexOf(sliceCard) > -1
                    {
                        DataSet dsCardDetails = DataManagerDevice.ProviderDevice.Users.ProvideCardUserDetails(cardID, userSource);
                        if (dsCardDetails.Tables[0].Rows.Count > 0)
                        {
                            //if (string.Compare(cardID, slicedCard, true) == 0) //cardID.IndexOf(sliceCard) > -1
                            //{

                            // Change the user source as per card ID;

                            string userCardSource = dsCardDetails.Tables[0].Rows[0]["USR_SOURCE"].ToString();
                            userSource            = userCardSource;
                            Session["UserSource"] = userSource;

                            bool isCardActive = bool.Parse(dsCardDetails.Tables[0].Rows[0]["REC_ACTIVE"].ToString());
                            domainName = dsCardDetails.Tables[0].Rows[0]["USR_DOMAIN"].ToString();
                            if (isCardActive)
                            {
                                allowedRetiresForLogin = int.Parse(DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideSetting("Allowed retries for user login"), CultureInfo.CurrentCulture);
                                string userID = dsCardDetails.Tables[0].Rows[0]["USR_ID"].ToString();
                                Session["UserID"] = userID;
                                string hashedPin            = Protector.ProvideEncryptedPin(password);
                                string userAuthenticationOn = dsCardDetails.Tables[0].Rows[0]["USR_ATHENTICATE_ON"].ToString();
                                // Authenticate PIN based on User Future Login Selection
                                if (userAuthenticationOn == Constants.AUTHENTICATE_FOR_PIN)
                                {
                                    if (hashedPin != dsCardDetails.Tables[0].Rows[0]["USR_PIN"].ToString())
                                    {
                                        if (allowedRetiresForLogin > 0)
                                        {
                                            isPinRetry = true;
                                            CheckCardRetryCount(userID, allowedRetiresForLogin);
                                        }
                                        else
                                        {
                                            Session["CardID"] = null;
                                            Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=invalidPin");
                                        }
                                        return;
                                    }
                                }
                                else
                                {
                                    string isSaveNetworkPassword = Session["NETWORKPASSWORD"].ToString();

                                    // If user source is AD/DM and network password is not saved
                                    // Then Authenticate user in Active Directory/Domain
                                    if (userSource != Constants.USER_SOURCE_DB && isSaveNetworkPassword == "False")
                                    {
                                        // Validate users based on source
                                        if (!AppAuthentication.isValidUser(userID, password, userDomain, userSource))
                                        {
                                            if (allowedRetiresForLogin > 0)
                                            {
                                                isPinRetry = false;
                                                CheckCardRetryCount(userID, allowedRetiresForLogin);
                                            }
                                            else
                                            {
                                                Session["CardID"] = null;
                                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=InvalidPassword");
                                            }
                                            return;
                                        }
                                    }
                                    else
                                    {
                                        // Check password is not null
                                        // Encrypt the password && Compare with Database password field
                                        if (!string.IsNullOrEmpty(password) && Protector.ProvideEncryptedPassword(password) != dsCardDetails.Tables[0].Rows[0]["USR_PASSWORD"].ToString())
                                        {
                                            if (allowedRetiresForLogin > 0)
                                            {
                                                isPinRetry = false;
                                                CheckCardRetryCount(userID, allowedRetiresForLogin);
                                            }
                                            else
                                            {
                                                Session["CardID"] = null;
                                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=InvalidPassword");
                                            }
                                            return;
                                        }
                                    }
                                }
                                string lastLogin = dsCardDetails.Tables[0].Rows[0]["REC_CDATE"].ToString();
                                if (string.IsNullOrEmpty(lastLogin) && userProvisioning == "First Time Use")
                                {
                                    if (!string.IsNullOrEmpty(dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString()))
                                    {
                                        userID = dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString();
                                    }
                                    Session["ftuUserID"]    = userID;
                                    Session["Username"]     = dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString();
                                    Session["ftuUsersysID"] = dsCardDetails.Tables[0].Rows[0]["USR_ACCOUNT_ID"].ToString();
                                    string printJobDomainName = DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideDomainName(domainName);
                                    Session["DomainName"] = printJobDomainName;
                                    Response.Redirect("FirstTimeUse.aspx");
                                }
                                string userSysID = dsCardDetails.Tables[0].Rows[0]["USR_ACCOUNT_ID"].ToString();
                                string DbuserID  = dsCardDetails.Tables[0].Rows[0]["USR_ID"].ToString();
                                if (DbuserID.ToLower() == "admin" || DbuserID.ToLower() == "administrator")
                                {
                                    Response.Redirect("MessageForm.aspx?FROM=CardLogOn.aspx&MESS=adminUserID");
                                    return;
                                }
                                Session["PRServer"]     = "";
                                Session["UserID"]       = DbuserID;
                                Session["Username"]     = dsCardDetails.Tables[0].Rows[0]["USR_NAME"].ToString();
                                Session["UserSystemID"] = userSysID;
                                if (userSource != Constants.USER_SOURCE_DB)
                                {
                                    string printJobDomainName = DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideDomainName(domainName);
                                    Session["DomainName"] = printJobDomainName;
                                }
                                string createDate = dsCardDetails.Tables[0].Rows[0]["REC_CDATE"].ToString();
                                if (string.IsNullOrEmpty(createDate))
                                {
                                    string updateCDate = DataManagerDevice.Controller.Users.UpdateCDate(userSysID);
                                }
                                RedirectPage();
                                return;
                            }
                            else
                            {
                                Session["CardID"] = null;
                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=AccountDisabled");
                            }
                        }
                        else
                        {
                            if (userProvisioning == "Self Registration" && userSource == "AD")
                            {
                                SelfRegisterCard();
                            }
                            else
                            {
                                Session["CardID"] = null;
                                Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=cardInfoNotFoundConsultAdmin");
                            }
                        }
                    }
                    else
                    {
                        Session["CardID"] = null;
                        Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=invalidCardId");
                    }
                }
                else
                {
                    if (!isValidFascilityCode)
                    {
                        Session["CardID"] = null;
                        Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=invalidCardId");
                    }
                    else
                    {
                        if (userProvisioning == "Self Registration" && userSource == "AD")
                        {
                            SelfRegisterCard();
                        }
                        else
                        {
                            Session["CardID"] = null;
                            Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=cardInfoNotFoundConsultAdmin");
                        }
                    }
                }
            }
            else
            {
                if (userProvisioning == "Self Registration" && userSource == "AD")
                {
                    SelfRegisterCard();
                }
                else
                {
                    Session["CardID"] = null;
                    Response.Redirect("MessageForm.aspx?FROM=Logon.aspx&MESS=cardInfoNotFoundConsultAdmin");
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Updates the user details.
        /// </summary>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/CD_PrintRoverWeb.AdministrationAddUsers.UpdateUserDetails.jpg"/>
        /// </remarks>
        private void UpdateUserDetails()
        {
            string userAccountId    = HdUserID.Value;
            string userID           = TextBoxUserID.Text.Trim();
            string userName         = TextBoxName.Text;
            string userPassword     = TextBoxPassword.Text;
            string userPin          = TextBoxPin.Text;
            string userCardID       = TextBoxCard.Text;
            string userEmail        = TextBoxEmail.Text;
            bool   isLoginEnabled   = CheckBoxEnableLogOn.Checked;
            string userLoginEnabled = "0";
            string userRole         = DropDown_UserRole.SelectedItem.Value.ToLower().ToString();
            string userCostCenter   = DropDownListCostCenters.SelectedValue;
            string department       = "1";
            //DropDownDepartment.SelectedValue;
            string authenticationMode   = string.Empty;
            string hashedPinNumber      = string.Empty;
            string auditMessage         = string.Empty;
            string authenticationServer = "Local";
            string auditorSource        = HostIP.GetHostIP();
            string isMyAccount          = DropDownListMyAccount.SelectedValue;
            string userCommand          = TextBoxPin.Text;

            if (isLoginEnabled)
            {
                userLoginEnabled = "1";
            }
            if (DropDown_UserRole.SelectedIndex == 0)
            {
                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "SELECT_USER_ROLE");
                GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                return;
            }

            //DataSet dsUserDetails = DataManager.Provider.Users.provideSelectedUserDetails(userID, userSource);
            DataSet dsUserDetails = DataManager.Provider.Users.provideSelectedUserDetails(userAccountId, userSource);

            if (TextBoxPassword.Text != Convert.ToString(dsUserDetails.Tables[0].Rows[0]["USR_PASSWORD"], CultureInfo.CurrentUICulture))
            {
                userPassword = Protector.ProvideEncryptedPassword(userPassword);
            }

            if (!string.IsNullOrEmpty(userCardID))
            {
                if (TextBoxCard.Text != Convert.ToString(dsUserDetails.Tables[0].Rows[0]["USR_CARD_ID"], CultureInfo.CurrentUICulture))
                {
                    if (DataManager.Controller.Card.IsCardExists(userCardID, userID))
                    {
                        string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "CARD_CONFIGURED_ANOTHER_USER");
                        GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                        return;
                    }
                    else
                    {
                        userCardID = Protector.ProvideEncryptedCardID(userCardID);
                    }
                }
            }
            string sqlAddonFilter = string.Format(CultureInfo.CurrentCulture, " USR_ID <> '{0}'", userID);

            if (!string.IsNullOrEmpty(userPin))
            {
                if (TextBoxPin.Text != Convert.ToString(dsUserDetails.Tables[0].Rows[0]["USR_PIN"], CultureInfo.CurrentUICulture))
                {
                    hashedPinNumber = Protector.ProvideEncryptedPin(TextBoxPin.Text);
                    if (DataManager.Controller.Users.IsOtherRecordExists("M_USERS", "USR_PIN", hashedPinNumber, sqlAddonFilter))
                    {
                        string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "PIN_ALREADY_USED");
                        GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage, null);
                        return;
                    }
                }
                else
                {
                    hashedPinNumber = TextBoxPin.Text;
                }
            }
            else
            {
                hashedPinNumber = TextBoxPin.Text;
            }
            try
            {
                string addSqlResponse = DataManager.Controller.Users.UpdateUserDetails(userSource, userAccountId, userName, userPassword, hashedPinNumber, userCardID, userEmail, userLoginEnabled, true, DropDownPrintProfile.SelectedValue, userRole, department, userCostCenter, isMyAccount, userCommand);

                if (string.IsNullOrEmpty(addSqlResponse))
                {
                    auditMessage = "User " + userID + " updated successfully";
                    LogManager.RecordMessage(auditorSource, Session["UserID"] as string, LogManager.MessageType.Success, auditMessage);
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_UPDATE_SUCCESS");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage, null);
                    GetUserDetails();
                    return;
                }
            }
            catch (Exception ex)
            {
                auditMessage = userID + " Failed to update User";
                LogManager.RecordMessage(auditorSource, Session["UserID"] as string, LogManager.MessageType.CriticalError, auditMessage, null, ex.Message, ex.StackTrace);
                string serverMessage1 = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USER_UPDATE_FAIL");
                GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage1, null);
                return;
            }
        }
    private void UpdateSettings()
    {
        string auditorSuccessMessage = "User " + Convert.ToString(Session["UserID"], CultureInfo.CurrentCulture) + ",Settings Updated  Successfully";
        string auditorFailureMessage = "User " + Convert.ToString(Session["UserID"], CultureInfo.CurrentCulture) + ", Failed to Update Settings";
        string auditorSource         = HostIP.GetHostIP();
        string messageOwner          = Convert.ToString(Session["UserID"], CultureInfo.CurrentCulture);

        Dictionary <string, string> newsettingvalue = new Dictionary <string, string>();
        int    settingTypeCount = int.Parse(HiddenFieldSettingType.Value, CultureInfo.CurrentCulture);
        string settingKey       = string.Empty;
        string settingValue     = string.Empty;

        for (int jobCount = 1; jobCount <= settingTypeCount; jobCount++)
        {
            settingKey   = Convert.ToString(Request.Form["__SETTINGKEY_" + jobCount], CultureInfo.CurrentCulture);
            settingValue = Convert.ToString(Request.Form["__SETTINGVALUE_" + jobCount], CultureInfo.CurrentCulture);
            if (settingKey == Constants.SETTINGKEY_AUTHSETTING)
            {
                Session["UserSource"] = settingValue;
            }
            if (settingKey == Constants.SETTINGKEY_DOMAIN)
            {
                if (string.IsNullOrEmpty(settingValue))
                {
                    GetSetting(applicationSettingCategory);
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "DOMAIN_FIELD_REQUIRED");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Warning.ToString(), serverMessage.ToString(), null);
                    return;
                }
            }
            else if (settingKey == Constants.SETTINGKEY_ADUSER)
            {
                if (string.IsNullOrEmpty(settingValue))
                {
                    GetSetting(applicationSettingCategory);
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "USERID_REQUIRED");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Warning.ToString(), serverMessage.ToString(), null);
                    return;
                }
            }
            else if (settingKey == Constants.SETTINGKEY_ADPASSWORD)
            {
                if (!string.IsNullOrEmpty(settingValue))
                {
                    settingValue = Protector.ProvideEncryptedPassword(settingValue);
                }
                else
                {
                    GetSetting(applicationSettingCategory);
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "PASSWORD_REQUIRED");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Warning.ToString(), serverMessage.ToString(), null);
                    return;
                }
            }
            newsettingvalue.Add(settingKey, settingValue);
            if (!string.IsNullOrEmpty(settingKey) && settingKey.Equals("AUDIT_LOG", StringComparison.OrdinalIgnoreCase))
            {
                Application["AUDITLOGCONFIGSTATUS"] = settingValue;
            }
        }

        if (string.IsNullOrEmpty(DataManager.Controller.Settings.UpdateGeneralSettings(newsettingvalue)))
        {
            // Store the latest values in Application variable
            HttpContext.Current.Application.Lock();
            Application["APP_SETTINGS"] = ApplicationSettings.ProvideApplicationSettings();
            HttpContext.Current.Application.UnLock();

            GetSetting(applicationSettingCategory);
            ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Success, auditorSuccessMessage);
            string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "SETTNG_UPDATE_SUCESS");
            GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null);
            return;
        }
        else
        {
            GetSetting(applicationSettingCategory);
            ApplicationAuditor.LogManager.RecordMessage(auditorSource, messageOwner, ApplicationAuditor.LogManager.MessageType.Error, auditorFailureMessage);
            string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "SETTNG_UPDATE_FAIL");
            GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null);
            return;
        }
    }
Ejemplo n.º 16
0
        /// <summary>
        /// Validates User password.
        /// </summary>
        /// <param name="userId">User id.</param>
        /// <param name="password">Password.</param>
        /// <param name="userDomain">User domain.</param>
        /// <remarks>
        /// Sequence Diagram:<br/>
        ///     <img src="SequenceDiagrams/SD_PrintReleaseEA.Mfp.ManualLogOn.ValidateUserPassword.jpg"/>
        /// </remarks>
        private void ValidateUserPassword(string userId, string password, string userDomain)
        {
            DataSet dsUserDetails = null;

            try
            {
                dsUserDetails = DataManagerDevice.ProviderDevice.Users.ProvideUserDetails(userId, userSource);
            }
            catch (Exception)
            {
                Response.Redirect("MessageForm.aspx?FROM=ManualLogOn.aspx&MESS=FailedToLogin");
                return;
            }

            if (dsUserDetails.Tables[0].Rows.Count > 0)
            {
                string hashedPin         = Protector.ProvideEncryptedPin(password);
                bool   userAccountActive = bool.Parse(dsUserDetails.Tables[0].Rows[0]["REC_ACTIVE"].ToString());
                if (userAccountActive)
                {
                    string isSaveNetworkPassword = Session["NETWORKPASSWORD"].ToString();
                    // Network password option is not required here. Since it is only applicable for Card Logon//
                    // Hence it is set to false.
                    isSaveNetworkPassword = "******";

                    // If user source is AD/DM and network password is not saved
                    // Then Authenticate user in Active Directory/Domain
                    if (userSource != Constants.USER_SOURCE_DB && isSaveNetworkPassword == "False")
                    {
                        //string applicationDomainName = DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideDomainName();
                        string applicationDomainName = dsUserDetails.Tables[0].Rows[0]["USR_DOMAIN"].ToString();
                        if (applicationDomainName == userDomain)
                        {
                            // Validate users based on source
                            if (!AppLibrary.AppAuthentication.isValidUser(userId, password, userDomain, userSource))
                            {
                                if (allowedRetiresForLogin > 0)
                                {
                                    isPinRetry = false;
                                    CheckPasswordRetryCount(userId, allowedRetiresForLogin);
                                }
                                else
                                {
                                    Response.Redirect("MessageForm.aspx?FROM=ManualLogOn.aspx&MESS=InvalidPassword");
                                }
                                return;
                            }
                        }
                        else
                        {
                            Response.Redirect("MessageForm.aspx?FROM=ManualLogOn.aspx&MESS=InvalidDomain");
                            return;
                        }
                    }
                    else
                    {
                        // Check password is not null
                        // Encrypt the password && Compare with Database password field
                        if (!string.IsNullOrEmpty(password) && Protector.ProvideEncryptedPassword(password) != dsUserDetails.Tables[0].Rows[0]["USR_PASSWORD"].ToString())
                        {
                            if (allowedRetiresForLogin > 0)
                            {
                                isPinRetry = false;
                                CheckPasswordRetryCount(userId, allowedRetiresForLogin);
                            }
                            else
                            {
                                Response.Redirect("MessageForm.aspx?FROM=ManualLogOn.aspx&MESS=InvalidPassword");
                            }
                            return;
                        }
                    }
                    //}

                    string userSysID = dsUserDetails.Tables[0].Rows[0]["USR_ACCOUNT_ID"].ToString();
                    if (!string.IsNullOrEmpty(userSysID))
                    {
                        string DbuserID = dsUserDetails.Tables[0].Rows[0]["USR_ID"].ToString();
                        Session["PRServer"]     = "";
                        Session["UserID"]       = DbuserID;
                        Session["Username"]     = dsUserDetails.Tables[0].Rows[0]["USR_NAME"].ToString();
                        Session["UserSystemID"] = userSysID;
                        if (userSource != Constants.USER_SOURCE_DB)
                        {
                            string printJobDomainName = DataManagerDevice.ProviderDevice.ApplicationSettings.ProvideDomainName(userDomain);
                            Session["DomainName"] = printJobDomainName;
                        }
                        string createDate = dsUserDetails.Tables[0].Rows[0]["REC_CDATE"].ToString();
                        if (string.IsNullOrEmpty(createDate))
                        {
                            string updateCDate = DataManagerDevice.Controller.Users.UpdateCDate(userSysID);
                        }
                        RedirectPage();
                        return;
                    }
                }
                else
                {
                    Response.Redirect("MessageForm.aspx?FROM=ManualLogOn.aspx&MESS=AccountDisabled");
                }
            }
            else
            {
                Response.Redirect("MessageForm.aspx?FROM=ManualLogOn.aspx&MESS=invalidUserTryAgain");
            }
        }
Ejemplo n.º 17
0
        private void UpdateADSettings()
        {
            string auditorSuccessMessage = "AD settings updated successfully";
            string auditorFailureMessage = "AD settings update failed";
            string auditorSource         = HostIP.GetHostIP();
            string suggestionMessage     = "Report to administrator";

            bool   isValuesChanged  = false;
            string domainController = TextBoxDomainController.Text.Trim();
            string domainName       = TextBoxDomainName.Text.Trim();
            string userName         = TextBoxUserName.Text.Trim();
            string textPassword     = TextBoxPassword.Text.Trim();
            string port             = TextBoxPort.Text.Trim();
            string attribute        = DropDownListFullName.SelectedValue;
            bool   isvaliduser      = LdapStoreManager.Ldap.AuthenticateUser(domainName, userName, textPassword, port);

            if (isvaliduser)
            {
                if (oldDomainController != domainController || oldDomainName != domainName || oldDomainUserName != userName || oldDomainUserPassword != textPassword || oldDomainPort != port || oldDomainNameAttribute != attribute)
                {
                    isValuesChanged = true;
                }
                else
                {
                    BindActiveDirectorySettings();
                    string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_SUCCESS");
                    GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null);

                    try
                    {
                        LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Success, auditorSuccessMessage);
                    }
                    catch (Exception)
                    {
                        //
                    }

                    return;
                }
            }
            else
            {
                string serverMessage = "Invalid AD Credentials or Domain name";
                GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null);
            }

            domainController = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxDomainController.Text.Trim());
            domainName       = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxDomainName.Text.Trim());
            userName         = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxUserName.Text.Trim());
            textPassword     = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxPassword.Text.Trim());
            port             = DataManager.Controller.FormatData.FormatSingleQuot(TextBoxPort.Text.Trim());

            Dictionary <string, string> dcADSettings = new Dictionary <string, string>();

            dcADSettings.Add("DOMAIN_CONTROLLER", domainController);
            dcADSettings.Add("DOMAIN_NAME", domainName);
            dcADSettings.Add("AD_USERNAME", userName);
            string password = Protector.ProvideEncryptedPassword(textPassword);

            dcADSettings.Add("AD_PASSWORD", password);
            dcADSettings.Add("AD_PORT", port);
            dcADSettings.Add("AD_FULLNAME", DropDownListFullName.SelectedValue);

            if (string.IsNullOrEmpty(DataManager.Controller.Settings.UpdateAcitiveDirectorySettingsNew(dcADSettings, domainName)))
            {
                // Clear the Cache upon successful database update
                if (isValuesChanged)
                {
                    try
                    {
                        if (Cache["LDAP_GROUPS"] != null)
                        {
                            Cache.Remove("LDAP_GROUPS");
                        }
                        //Cache["LDAP_GROUPS"] = null;

                        if (Cache["ALL_USERS"] != null)
                        {
                            Cache.Remove("ALL_USERS");
                        }
                        //Cache["ALL_USERS"] = null;
                    }
                    catch (Exception)
                    {
                    }
                }

                BindActiveDirectorySettings();
                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_SUCCESS");
                GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Success.ToString(), serverMessage.ToString(), null);

                Application["JOBCONFIGURATION"] = ApplicationSettings.ProvideJobConfiguration();

                try
                {
                    LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Success, auditorSuccessMessage);
                }
                catch (IOException exceptionMessage)
                {
                    LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Exception, auditorFailureMessage, suggestionMessage, exceptionMessage.Message, exceptionMessage.StackTrace);
                }
                catch (NullReferenceException exceptionMessage)
                {
                    LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Exception, auditorFailureMessage, suggestionMessage, exceptionMessage.Message, exceptionMessage.StackTrace);
                }
                catch (Exception exceptionMessage)
                {
                    LogManager.RecordMessage(auditorSource, AUDITORSOURCE, LogManager.MessageType.Exception, auditorFailureMessage, suggestionMessage, exceptionMessage.Message, exceptionMessage.StackTrace);
                }
                return;
            }

            else
            {
                BindActiveDirectorySettings();
                string serverMessage = Localization.GetServerMessage("", Session["selectedCulture"] as string, "AD_SETTING_UPDATE_FAILED");
                GetMasterPage().DisplayActionMessage(AppLibrary.MessageType.Error.ToString(), serverMessage.ToString(), null);
                return;
            }
        }