static bool DeleteKey(string key)
 {
     using (var credential = new Credential())
     {
         credential.Target = key;
         if (!credential.Load())
             return false;
         return credential.Delete();
     }
 }
 public Task<Credentials> GetCredentials()
 {
     var keyHost = GetKeyHost(hostAddress.CredentialCacheKeyHost);
     using (var credential = new Credential())
     {
         credential.Target = keyHost;
         credential.Type = CredentialType.Generic;
         if (credential.Load())
             return Task.FromResult(new Credentials(credential.Username, credential.Password));
     }
     return Task.FromResult(Credentials.Anonymous);
 }
示例#3
0
        public bool Exists()
        {
            CheckNotDisposed();
            _unmanagedCodePermission.Demand();

            if (string.IsNullOrEmpty(Target))
            {
                throw new InvalidOperationException("Target must be specified to check existance of a credential.");
            }

            using (Credential existing = new Credential { Target = Target, Type = Type })
            {
                return existing.Load();
            }
        }