private void btnSave_Click(object sender, EventArgs e) { objCre = new Credential(); objCre.Username = txtUserName.Text.Trim(); objCre.Password = txtPassword.Text.Trim(); objCre.Target = txtDomainKey.Text.Trim(); if (!ControlsValidate()) { MessageBox.Show("Enter all fields"); } else { if (objCre.Exists()) { MessageBox.Show("Sorry, Already Exists!"); } else { objCre.Save(); MessageBox.Show("Saved!"); ClearFields(); LoadCredential(false); } } }
public bool SaveCredential(string username, string password) { _logger.Info("Saving credentials to store..."); using (var credential = new CredentialManagement.Credential()) { credential.Target = RaceControlF1TV; credential.Type = CredentialType.Generic; credential.PersistanceType = PersistanceType.LocalComputer; credential.Username = username; credential.Password = password; var saved = credential.Save(); if (saved) { _logger.Info("Credentials saved to store."); } else { _logger.Warn("Credentials not saved to store."); } return(saved); } }
public void Store(string username, string password) { using (var cred = new Credential(username, password, TheProduct.CredentialsTarget, CredentialType.Generic) { PersistanceType = PersistanceType.Enterprise }) { if (cred.Save()) { OnChanged(); } else { throw new InvalidOperationException("Couldn't save credential to store"); } } }
public void SaveCredential(string username, string password) { using var credential = new CredentialManagement.Credential { Target = RaceControlF1TV, Type = CredentialType.Generic, PersistanceType = PersistanceType.LocalComputer, Username = username, Password = password }; if (credential.Save()) { _logger.Info("Credentials saved to store."); } else { _logger.Warn("Credentials not saved to store."); } }
private Credential GetCredFromUser() { var prompt = CredentialsPromptProvider.Prompt; if (prompt.ShowDialog() == DialogResult.OK) { var cred = new Credential { Type = CredentialType.Generic, PersistanceType = PersistanceType.LocalComputer, Target = serverUri.ToString(), Username = prompt.Username, Password = prompt.Password }; cred.Save(); return cred; } else { return null; } }
/// <summary> /// The set credentials. /// </summary> /// <param name="userName"> /// The user name. /// </param> /// <param name="password"> /// The password. /// </param> private void SetCredentials(string userName, string password) { this.configurationHelper.WriteSetting(new SonarQubeProperties(Context.GlobalPropsId, OwnersId.ApplicationOwnerId, "ServerAddress", this.ServerAddress)); using (var cm = new Credential { Target = "VSSonarQubeExtension", PersistanceType = PersistanceType.Enterprise, Username = userName, SecurePassword = ConnectionConfiguration.ConvertToSecureString(password) }) { cm.Save(); } }
/// <summary> /// Saves the provided OneDrive Refresh Token in the Windows Credential Manager /// </summary> /// <param name="databaseFilePath">Full local path to the KeePass database for which to save the OneDrive Refresh Token</param> /// <param name="refreshToken">The OneDrive Refresh Token to store securely in the Windows Credential Manager</param> public static void SaveRefreshTokenInWindowsCredentialManager(string databaseFilePath, string refreshToken) { using (var saved = new Credential(string.Empty, refreshToken, string.Concat("KoenZomers.KeePass.OneDriveSync:", databaseFilePath), CredentialType.Generic) {PersistanceType = PersistanceType.LocalComputer}) { saved.Save(); } }
private static void CredentialManagement() { //var cm = new CredentialManagement.CredentialSet(); ////{ //// Target = "192.168.20.30", //// //PersistanceType = PersistanceType.Enterprise, //// //Username = "******", //// //Password = "******", //// ////Type = CredentialType.None ////}; ////cm.Save(); //cm.Load(); //var item = cm.FirstOrDefault(cc => cc.Target == "192.168.20.30"); //{ // Console.WriteLine(item.Target + " " + item.PersistanceType + " " + item.Type + " " + item.Username + ":" + item.Password); //} var c = new Credential() { Target = "192.168.20.30", Type = CredentialType.DomainPassword,//windows 凭证 Generic 普通凭证 PersistanceType = PersistanceType.Enterprise,//永久 Username = "******", Password = "******" }; c.Save(); }
public static System.Net.NetworkCredential GetCredential(string serverip) { System.Net.NetworkCredential credentials = null; BaseCredentialsPrompt prompt = null; if (IsWinVistaOrHigher()) { prompt = new VistaPrompt(); Console.WriteLine("win7"); } else { prompt = new XPPrompt() { Target = serverip }; Console.WriteLine("xp"); } prompt.SaveChecked = true; prompt.ShowSaveCheckBox = true; prompt.Title = @"指定已授权的 域(计算机)\用户"; try { if (prompt.ShowDialog() == DialogResult.OK) { credentials = new System.Net.NetworkCredential(prompt.Username, prompt.SecurePassword); if (prompt.SaveChecked) { var cm = new Credential() { Target = serverip, Type = CredentialType.DomainPassword,//windows 凭证 Generic 普通凭证 PersistanceType = PersistanceType.Enterprise,//永久 Username = prompt.Username, SecurePassword = prompt.SecurePassword }; cm.Save(); } return credentials; } } catch (Exception ex) { Console.WriteLine(ex.GetBaseException()); } return null; }
public bool Apply(PasswordBox password) { if (string.IsNullOrEmpty(NewUser) || string.IsNullOrEmpty(NewCredential) || password.SecurePassword.Length == 0) return false; var cred = new Credential(NewUser, ConvertToUnsecureString(password.SecurePassword), NewCredential, Type) { SecurePassword = password.SecurePassword, PersistanceType = PersistanceType.LocalComputer }; return cred.Save(); }