Beispiel #1
0
 /// <summary>
 /// Get mailpassword from registry entry
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 public static string GetRegistryPassword(Credentials c)
 {
     using (RegistryKey k = Registry.CurrentUser.OpenSubKey("Software")?.OpenSubKey("Bestellsoftware"))
     {
         return(Crypting.DecryptString(k.GetValue("Passwort").ToString(), SecureStringHandler.SecureStringToString(c.Password)));                   //Rückgabe des entschlüsselten Passworts
     }
 }
Beispiel #2
0
        /// <summary>
        /// Check if login information are correct
        /// </summary>
        public void IsValid(Credentials credentials)
        {
            try
            {
                using (var p = new PrincipalContext(ContextType.Domain, credentials.Domain))
                {
                    if (!p.ValidateCredentials(credentials.Username, SecureStringHandler.SecureStringToString(credentials.Password)))                 //Wenn Benutzerdaten falsch sind
                    {
                        Valid = false;
                        return;
                    }

                    Valid = IsGroupValid(credentials, p);                                                                //Wenn Benutzerdaten richtig sind wird die Gruppe überprüft
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #3
0
        private async void button_enter_Click(object sender, EventArgs e)
        {
            Credentials cred = new Credentials
            {
                Username = textBox_username.Text,
                Domain   = Settings.Default.WindowsDomain,
            };

            SecureStringHandler.StringToSecureString(ref cred.Password, textBox_password.Text);

            textBox_password.Text = "";
            DomainAuthentification d = new DomainAuthentification(this.Controls);

            LoadingScreen();

            await Task.Factory.StartNew(() =>
            {
                d.IsValid(cred);
            });

            if (d.Valid)
            {
                await d.PasswordInRegistry(cred);

                SqlOperations sql = new SqlOperations(new SqlConnectionStringBuilder()
                {
                    DataSource = "127.0.0.1\\BESTELLSOFTWARE", IntegratedSecurity = true, InitialCatalog = "bestellsoftware"
                }.ToString());
                MessageBox.Show(sql.Authenticate.ToString());
                Hide();
                UI u = new UI(cred);
                u.ShowDialog();
                Close();
            }
            else
            {
                InputScreen();
                MessageBox.Show(Lang.GetText("message_authentification_wrongcredentials"));
            }
        }