Exemple #1
0
 private void inCacheToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (lvwUserNameCache.SelectedItems.Count == 1)
     {
         QuickMon.Security.CredentialManager credMan = new Security.CredentialManager();
         try
         {
             credMan.MasterKey = txtApplicationMasterKey.Text;
             if (txtApplicationMasterKeyFilePath.Text.Length > 0 && System.IO.File.Exists(txtApplicationMasterKeyFilePath.Text))
             {
                 credMan.OpenCache(txtApplicationMasterKeyFilePath.Text);
                 if (credMan.IsAccountPersisted(lvwUserNameCache.SelectedItems[0].Text))
                 {
                     if (credMan.IsAccountDecryptable(lvwUserNameCache.SelectedItems[0].Text))
                     {
                         MessageBox.Show("Selected user account is in the cache and can be decrypted with specified master key.", "Cache", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                     else
                     {
                         MessageBox.Show("Selected user account is in the cache but it cannot be decrypted with specified master key!", "Cache", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Selected user account is not in the cache", "Cache", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Exemple #2
0
        public static bool IsAccountPersisted(string persistedStorageLocation, string masterKey, string username)
        {
            bool found = false;

            try
            {
                CredentialManager credMan = new CredentialManager();
                credMan.MasterKey = masterKey;
                credMan.OpenCache(persistedStorageLocation);
                found = credMan.IsAccountPersisted(username);
            }
            catch { }
            return(found);
        }