public void XPPrompt_ShowDialog_WithParent_ShouldNotThrowError() { XPPrompt prompt = GetDefaultPrompt(); prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_Without_Target_ShouldThrowError() { XPPrompt prompt = new XPPrompt(); Testing.ShouldThrowException <InvalidOperationException>(() => prompt.ShowDialog()); prompt.Dispose(); }
public void XPPrompt_ShowDialog_ShouldNotThrowError() { XPPrompt prompt = GetDefaultPrompt(); prompt.ShowDialog(); prompt.Dispose(); }
private void ShowWindowsCredentialDialog() { try { //if (Environment.OSVersion.Version.Major >= 6) //{ XPPrompt xp = new XPPrompt(); xp.AlwaysShowUI = true; xp.CompleteUsername = true; xp.DoNotPersist = false; xp.ExpectConfirmation = true; xp.GenericCredentials = true; xp.Message = "Enter the credentials for AMT"; xp.RequestAdministrator = true; xp.ShowSaveCheckBox = true; xp.Target = "Sample"; xp.ValidateUsername = true; xp.ShowDialog(); } catch (Exception ex) { AMTLogger.WriteToLog(ex.Message, MethodBase.GetCurrentMethod().Name, 0, AMTLogger.LogInfo.Error); } }
public void XPPrompt_ShowDialog_Persist() { XPPrompt prompt = GetDefaultPrompt(); prompt.Persist = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_ShowSaveCheckBox() { XPPrompt prompt = GetDefaultPrompt(); prompt.ShowSaveCheckBox = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_UsernameReadOnly() { XPPrompt prompt = GetDefaultPrompt(); prompt.UsernameReadOnly = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
private XPPrompt GetDefaultPrompt() { XPPrompt prompt = new XPPrompt { Target = "target" }; return(prompt); }
public void XPPrompt_ShowDialog_RequreSmartCard() { XPPrompt prompt = GetDefaultPrompt(); prompt.RequireSmartCard = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_RequestAdministrator() { XPPrompt prompt = GetDefaultPrompt(); prompt.RequestAdministrator = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_GenericCredentials() { XPPrompt prompt = GetDefaultPrompt(); prompt.GenericCredentials = true; prompt.ShowDialog(IntPtr.Zero).ShouldEqual(DialogResult.OK); prompt.Dispose(); }
public void XPPrompt_ShowDialog_IncorrectPassword() { XPPrompt prompt = GetDefaultPrompt(); prompt.IncorrectPassword = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_ExpectConfirmation() { XPPrompt prompt = GetDefaultPrompt(); prompt.ExpectConfirmation = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_ExcludeCertificates() { XPPrompt prompt = GetDefaultPrompt(); prompt.ExcludeCertificates = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_AlwaysShowUI_Without_GenericCredentials_ShouldThrowError() { XPPrompt prompt = GetDefaultPrompt(); prompt.AlwaysShowUI = true; Testing.ShouldThrowException <InvalidOperationException>(() => prompt.ShowDialog(IntPtr.Zero)); prompt.Dispose(); }
public void XPPrompt_ShowDialog_ValidateUsername() { XPPrompt prompt = GetDefaultPrompt(); prompt.ValidateUsername = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_RequreCertificate() { XPPrompt prompt = GetDefaultPrompt(); prompt.RequireCertificate = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_AlwaysShowUI() { XPPrompt prompt = GetDefaultPrompt(); prompt.AlwaysShowUI = true; prompt.GenericCredentials = true; prompt.ShowDialog(IntPtr.Zero); prompt.Dispose(); }
public void XPPrompt_ShowDialog_With_Username() { XPPrompt prompt = GetDefaultPrompt(); prompt.Username = "******"; prompt.Title = "Enter enter valid credentials."; prompt.Message = "Please enter valid credentials."; prompt.ShowSaveCheckBox = true; prompt.GenericCredentials = true; prompt.ShowDialog().ShouldEqual(DialogResult.OK); prompt.Dispose(); }
public static System.Net.NetworkCredential GetCredential(string serverip) { System.Net.NetworkCredential credentials = null; BaseCredentialsPrompt prompt = null; if (IsWinVistaOrHigher()) { prompt = new VistaPrompt(); Console.WriteLine("win7"); } else { prompt = new XPPrompt() { Target = serverip }; Console.WriteLine("xp"); } prompt.SaveChecked = true; prompt.ShowSaveCheckBox = true; prompt.Title = @"指定已授权的 域(计算机)\用户"; try { if (prompt.ShowDialog() == DialogResult.OK) { credentials = new System.Net.NetworkCredential(prompt.Username, prompt.SecurePassword); if (prompt.SaveChecked) { var cm = new Credential() { Target = serverip, Type = CredentialType.DomainPassword, //windows 凭证 Generic 普通凭证 PersistanceType = PersistanceType.Enterprise, //永久 Username = prompt.Username, SecurePassword = prompt.SecurePassword }; cm.Save(); } return(credentials); } } catch (Exception ex) { Console.WriteLine(ex.GetBaseException()); } return(null); }
public void test() { XPPrompt xp = new XPPrompt(); xp.AlwaysShowUI = true; xp.CompleteUsername = true; xp.DoNotPersist = false; xp.ExpectConfirmation = true; xp.GenericCredentials = true; xp.Message = "Enter the credentials for AMT"; xp.RequestAdministrator = true; xp.ShowSaveCheckBox = true; xp.Target = "Sample"; xp.ValidateUsername = true; }
private static WebLearnCredential PromptForCredential() { var prompt = new XPPrompt { Target = Target, Persist = true }; if (prompt.ShowDialog() != DialogResult.OK) { return(null); } var cred = CredentialTemplate(); cred.Username = prompt.Username.Split(new[] { '\\' }, 2)[1]; cred.Password = prompt.Password; cred.Save(); return(Convert(cred)); }
private XPPrompt GetDefaultPrompt() { XPPrompt prompt = new XPPrompt {Target = "target"}; return prompt; }
public void XPPrompt_ShowDialog_Without_Target_ShouldThrowError() { XPPrompt prompt = new XPPrompt(); Testing.ShouldThrowException<InvalidOperationException>(() => prompt.ShowDialog()); prompt.Dispose(); }