Exemplo n.º 1
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (!IsInSecurityWindow &&
         Userods.EncryptPassword(textCurrent.Text) != Security.CurUser.Password)
     {
         MsgBox.Show(this, "Current password incorrect.");
         return;
     }
     if (PrefC.GetBool(PrefName.PasswordsMustBeStrong))
     {
         string explanation = Userods.IsPasswordStrong(textPassword.Text);
         if (explanation != "")
         {
             MessageBox.Show(explanation);
             return;
         }
     }
     if (textPassword.Text == "")
     {
         hashedResult = "";
     }
     else
     {
         hashedResult = Userods.EncryptPassword(textPassword.Text);
     }
     //MessageBox.Show(hashedResult);
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = (Userod)listUser.SelectedItem;

            if (!Userods.CheckTypedPassword(textPassword.Text, selectedUser.Password))
            {
                MsgBox.Show(this, "Incorrect password");
                return;
            }
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "")
            {
                MsgBox.Show(this, "When using the web service, not allowed to log in with no password.  A password should be added for this user.");
                return;
            }
            Security.CurUser = selectedUser.Copy();
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                string password = textPassword.Text;
                if (Programs.UsingEcwTight())                 //ecw requires hash, but non-ecw requires actual password
                {
                    password = Userods.EncryptPassword(password, true);
                }
                Security.PasswordTyped = password;
            }
            if (PrefC.GetBool(PrefName.TasksCheckOnStartup))
            {
                int taskcount = Tasks.UserTasksCount(Security.CurUser.UserNum);
                if (taskcount > 0)
                {
                    MessageBox.Show(Lan.g(this, "There are ") + taskcount + Lan.g(this, " unread tasks on your tasklists."));
                }
            }
            Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end");
            DialogResult = DialogResult.OK;
        }
Exemplo n.º 3
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textOnlinePassword.Text != "" && textOnlinePassword.Text != "********")
     {
         if (!PasswordIsValid())
         {
             return;
         }
         if (!WasPrinted)
         {
             DialogResult result = MessageBox.Show(Lan.g(this, "Online Password changed but was not printed, would you like to print?"), Lan.g(this, "Print Patient Info"), MessageBoxButtons.YesNoCancel);
             if (result == DialogResult.Yes)
             {
                 //Print the showing information.
                 PrintPatientInfo();
             }
             else if (result == DialogResult.No)
             {
                 //User does not want to print.  Do nothing.
             }
             else if (result == DialogResult.Cancel)
             {
                 return;
             }
         }
         PatCur.OnlinePassword = Userods.EncryptPassword(textOnlinePassword.Text, false);
         Patients.Update(PatCur, PatOld);
     }
     DialogResult = DialogResult.OK;
 }
Exemplo n.º 4
0
 ///<summary>Only called at startup if this dialog is not supposed to be shown.  Must call GetConfig first.</summary>
 public bool TryToConnect()
 {
     if (checkConnectServer.Checked)            // && checkUsingEcw.Checked){
     //js commented this portion out in version 12.0 on 1/7/11.  Must hunt down resulting bugs.
     //if(!checkUsingEcw.Checked) {//Can't silently connect unless using eCW.
     //	return false;
     //}
     {
         RemotingClient.ServerURI = textURI.Text;
         try{
             //ecw requires hash, but non-ecw requires actual password
             if (checkUsingEcw.Checked)
             {
                 //this handles situation where an eCW user passes in an actual OdPassword
                 string password = OdPassHash;
                 if (OdPassword != "")
                 {
                     password = Userods.EncryptPassword(OdPassword, true);
                 }
                 Security.CurUser       = Security.LogInWeb(textUser2.Text, password, "", Application.ProductVersion, true);
                 Security.PasswordTyped = password;                      //so we really store the encrypted pw if ecw user passes in their real password?
             }
             else
             {
                 Security.CurUser       = Security.LogInWeb(textUser2.Text, OdPassword, "", Application.ProductVersion, false);
                 Security.PasswordTyped = OdPassword;
             }
             RemotingClient.RemotingRole = RemotingRole.ClientWeb;
             return(true);
         }
         catch {
             return(false);
         }
     }
     OpenDentBusiness.DataConnection dcon = new OpenDentBusiness.DataConnection();
     //Try to connect to the database directly
     try {
         if (textConnectionString.Text.Length > 0)
         {
             dcon.SetDb(textConnectionString.Text, "", DataConnection.DBtype);
         }
         else
         {
             dcon.SetDb(comboComputerName.Text, comboDatabase.Text, textUser.Text, textPassword.Text, "", "", DataConnection.DBtype);
         }
         //a direct connection does not utilize lower privileges.
         RemotingClient.RemotingRole = RemotingRole.ClientDirect;
         return(true);
     }
     catch (Exception ex) {
         return(false);
     }
 }
Exemplo n.º 5
0
 private void butGiveAccess_Click(object sender, EventArgs e)
 {
     if (butGiveAccess.Text == "Provide Online Access")           //When form open opens with a blank password
     {
         string error = ValidatePatientAccess();
         if (error != "")
         {
             MessageBox.Show(error);
             return;
         }
         Cursor = Cursors.WaitCursor;
         //1. Fill password.
         string passwordGenerated = GenerateRandomPassword(8);
         textOnlinePassword.Text = passwordGenerated;
         //2. Make the password editable in case they want to change it.
         textOnlinePassword.ReadOnly = false;
         //3. Save password to db.
         // We only save the hash of the generated password.
         string passwordHashed = Userods.EncryptPassword(passwordGenerated, false);
         PatCur.OnlinePassword = passwordHashed;
         Patients.Update(PatCur, PatOld);
         PatOld.OnlinePassword = passwordHashed;              //Update PatOld in case the user changes password manually.
         //4. Insert EhrMeasureEvent
         EhrMeasureEvent newMeasureEvent = new EhrMeasureEvent();
         newMeasureEvent.DateTEvent = DateTime.Now;
         newMeasureEvent.EventType  = EhrMeasureEventType.OnlineAccessProvided;
         newMeasureEvent.PatNum     = PatCur.PatNum;
         newMeasureEvent.MoreInfo   = "";
         EhrMeasureEvents.Insert(newMeasureEvent);
         //5. Rename button
         butGiveAccess.Text = "Remove Online Access";
         Cursor             = Cursors.Default;
     }
     else              //remove access
     {
         Cursor = Cursors.WaitCursor;
         //1. Clear password
         textOnlinePassword.Text = "";
         //2. Make in uneditable
         textOnlinePassword.ReadOnly = true;
         //3. Save password to db
         PatCur.OnlinePassword = textOnlinePassword.Text;
         Patients.Update(PatCur, PatOld);
         PatOld.OnlinePassword = textOnlinePassword.Text;              //Update PatOld in case the user changes password manually.
         //4. Rename button
         butGiveAccess.Text = "Provide Online Access";
         Cursor             = Cursors.Default;
     }
 }
Exemplo n.º 6
0
        private void butGenerate_Click(object sender, EventArgs e)
        {
            if (textOnlinePassword.ReadOnly)
            {
                MessageBox.Show("Please use the Provide Online Access button first.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            string passwordGenerated = GenerateRandomPassword(8);

            textOnlinePassword.Text = passwordGenerated;
            // We only save the hash of the generated password.
            string passwordHashed = Userods.EncryptPassword(passwordGenerated, false);

            PatCur.OnlinePassword = passwordHashed;
            Patients.Update(PatCur, PatOld);
            PatOld.OnlinePassword = passwordHashed;          //Update PatOld in case the user changes password manually.
            Cursor = Cursors.Default;
        }
Exemplo n.º 7
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (checkConnectServer.Checked)
     {
         string originalURI = RemotingClient.ServerURI;
         RemotingClient.ServerURI = textURI.Text;
         bool useEcwAlgorithm = checkUsingEcw.Checked;
         try{
             string password = textPassword2.Text;
             if (useEcwAlgorithm)
             {
                 password = Userods.EncryptPassword(password, true);
             }
             //ecw requires hash, but non-ecw requires actual password
             Userod user = Security.LogInWeb(textUser2.Text, password, "", Application.ProductVersion, useEcwAlgorithm);
             Security.CurUser            = user;
             Security.PasswordTyped      = password;             //for ecw, this is already encrypted.//textPassword2.Text;
             RemotingClient.RemotingRole = RemotingRole.ClientWeb;
         }
         catch (Exception ex) {
             RemotingClient.ServerURI = originalURI;
             MessageBox.Show(ex.Message);
             return;
         }
     }
     else
     {
         OpenDentBusiness.DataConnection dcon;
         //Try to connect to the database directly
         try {
             DataConnection.DBtype = DatabaseType.MySql;
             if (listType.SelectedIndex == 1)
             {
                 DataConnection.DBtype = DatabaseType.Oracle;
             }
             dcon = new OpenDentBusiness.DataConnection(DataConnection.DBtype);
             if (textConnectionString.Text.Length > 0)
             {
                 dcon.SetDb(textConnectionString.Text, "", DataConnection.DBtype);
             }
             else
             {
                 dcon.SetDb(comboComputerName.Text, comboDatabase.Text, textUser.Text, textPassword.Text, "", "", DataConnection.DBtype);
             }
             //a direct connection does not utilize lower privileges.
         }
         catch (Exception ex) {
             MessageBox.Show(                    //Lan.g(this,"Could not establish connection to database."));
                 ex.Message);
             return;
         }
         RemotingClient.RemotingRole = RemotingRole.ClientDirect;
     }
     try{
         XmlWriterSettings settings = new XmlWriterSettings();
         settings.Indent      = true;
         settings.IndentChars = ("    ");
         using (XmlWriter writer = XmlWriter.Create(ODFileUtils.CombinePaths(Application.StartupPath, "FreeDentalConfig.xml"), settings)) {
             writer.WriteStartElement("ConnectionSettings");
             if (textConnectionString.Text != "")
             {
                 writer.WriteStartElement("ConnectionString");
                 writer.WriteString(textConnectionString.Text);
                 writer.WriteEndElement();
             }
             else if (RemotingClient.RemotingRole == RemotingRole.ClientDirect)
             {
                 writer.WriteStartElement("DatabaseConnection");
                 writer.WriteStartElement("ComputerName");
                 writer.WriteString(comboComputerName.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Database");
                 writer.WriteString(comboDatabase.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("User");
                 writer.WriteString(textUser.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Password");
                 writer.WriteString(textPassword.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("NoShowOnStartup");
                 if (checkNoShow.Checked)
                 {
                     writer.WriteString("True");
                 }
                 else
                 {
                     writer.WriteString("False");
                 }
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             else if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
             {
                 writer.WriteStartElement("ServerConnection");
                 writer.WriteStartElement("URI");
                 writer.WriteString(textURI.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("UsingEcw");
                 if (checkUsingEcw.Checked)
                 {
                     writer.WriteString("True");
                 }
                 else
                 {
                     writer.WriteString("False");
                 }
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             writer.WriteStartElement("DatabaseType");
             if (listType.SelectedIndex == 0)
             {
                 writer.WriteString("MySql");
             }
             else
             {
                 writer.WriteString("Oracle");
             }
             writer.WriteEndElement();
             writer.WriteEndElement();
             writer.Flush();
         }                //using writer
     }
     catch {
         //data not saved.
     }
     //fyiReporting.RDL.DataSource.SetOpenDentalConnectionString(
     //	"Server="+ComputerName+";Database="+Database+";User ID="+DbUser+";Password="******";CharSet=utf8");
     DialogResult = DialogResult.OK;
 }