/// <summary> /// Set the credentials for the target in the windows credential manager /// </summary> /// <param name="target">target of the credentials</param> /// <returns>true - credentials set. false - failure to set credentials </returns> public bool SetCredentials(string target) { ICredentialWrapper cred = _factory.CreateCredential(); cred.Target = target; cred.Username = _identity.Name; cred.SecurePassword = GetSecurePasswordFromConsole(); cred.Type = CredentialType.Generic; return(cred.Save()); }
/// <summary> /// Retrieve the credentials for the target from the windows credential manager /// </summary> /// <param name="target">target of the credentials</param> /// <returns>user name and password</returns> public (string user, SecureString password) GetCredentials(string target) { ICredentialWrapper cred = _factory.CreateCredential(); cred.Target = target; if (!cred.Load()) { return(user : null, password : null); } return(user : cred.Username, password : cred.SecurePassword); }