コード例 #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
ファイル: SecurityUtilities.cs プロジェクト: zachwieja/RTVS
 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));
            }
        }