Пример #1
0
 private Credentials ReadSavedCredentials(string authority)
 {
     using (var ch = CredentialHandle.ReadFromCredentialManager(authority)) {
         if (ch != null)
         {
             var credData = ch.GetCredentialData();
             return(Credentials.Create(credData.UserName, SecurityUtilities.SecureStringFromNativeBuffer(credData.CredentialBlob)));
         }
         return(null);
     }
 }
Пример #2
0
 public static Credentials ReadCredentials(string authority)
 {
     using (CredentialHandle ch = CredentialHandle.ReadFromCredentialManager(authority)) {
         if (ch != null)
         {
             CredentialData credData = ch.GetCredentialData();
             return(Credentials.CreateSavedCredentails(credData.UserName, SecureStringFromNativeBuffer(credData.CredentialBlob)));
         }
         return(null);
     }
 }
Пример #3
0
 public string GetUserName(string authority)
 {
     using (var ch = CredentialHandle.ReadFromCredentialManager(authority)) {
         if (ch != null)
         {
             var credData = ch.GetCredentialData();
             return(credData.UserName);
         }
         return(string.Empty);
     }
 }
Пример #4
0
        public (string username, SecureString password) ReadUserCredentials(string authority)
        {
            using (var ch = CredentialHandle.ReadFromCredentialManager(authority)) {
                if (ch == null)
                {
                    return(null, null);
                }

                var credData = ch.GetCredentialData();
                return(credData.UserName, SecurityUtilities.SecureStringFromNativeBuffer(credData.CredentialBlob));
            }
        }