public bool DeletePassword(string credentialId) { using (Win32Credential cred = new Win32Credential() { Target = credentialId, Username = AnyUsername }) { return(cred.Delete()); } }
public bool Save(Credential credential) { Credential.ValidateForSave(credential); using (Win32Credential cred = new Win32Credential(AnyUsername, credential.Password, credential.CredentialId, CredentialType.Generic) { PersistanceType = PersistanceType.LocalComputer }) { return(cred.Save()); } }
public bool Exists() { CheckNotDisposed(); if (string.IsNullOrEmpty(Target)) { throw new InvalidOperationException(SR.CredentialsServiceTargetForLookup); } using (Win32Credential existing = new Win32Credential { Target = Target, Type = Type }) { return(existing.Load()); } }
public bool TryGetPassword(string credentialId, out string password) { Validate.IsNotNullOrEmptyString("credentialId", credentialId); password = null; using (CredentialSet set = new CredentialSet(credentialId).Load()) { // Note: Credentials are disposed on disposal of the set Win32Credential foundCred = null; if (set.Count > 0) { foundCred = set[0]; } if (foundCred != null) { password = foundCred.Password; return(true); } return(false); } }