如何在WinForm上创建安全的身份验证表单 [英] how to create secured authentication form on WinForm

查看:91
本文介绍了如何在WinForm上创建安全的身份验证表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

早上好,
如何创建像WinLogon这样的安全身份验证表单?
要求:用户无法访问其他表单和其他应用程序.
我创建了一些有关使用API​​函数CreateDesktop和SwitchDesktop在Win2k以上的Windows中管理桌面的信息.但是,当我将主表单保留在默认桌面中时,我无法将其登录表单放置在登录桌面中.
我创建了自然界中存在的安全桌面",但是我没有足够的信息来实现Winlogon等Winform.
也许我可以将其他技术与WinForm一起使用.

Good day,
how to create secured authentication form like WinLogon?
requirements: user can''t get access to other forms and other application.
I founded some infomation about managing desktops in Windows above Win2k with using API functions CreateDesktop and SwitchDesktop. But I can''t place my login form in login desktop when i keep my main form in default desktop.
I founded what "secured desktop" is exists in nature, but i have not enought information for realization of winform like winlogon.
May be I can use other technologies with WinForm.

推荐答案

这将是对OS的滥用,因此也难怪OS不允许您这样做.常规的Forms应用程序.无论如何,您将无法禁用Ctrl + Alt + Del,然后显示任务管理器并结束过程.



但是,请参见以下讨论:
c#程序ctrl-alt-del屏幕窗口7 [ ^ ].

例如,对于Web应用程序,有一个Kiosk模式.请参阅:
使用C#以Kiosk模式运行网站 [
This would be abuse of the OS, so no wonder that OS won''t allow you to do it by a regular Forms application. Any in any case, you won''t be able to disable Ctrl+Alt+Del followed by showing the Task Manager and ending of your process.



However, please see this discussion:
c# program ctrl-alt-del screen windows 7[^].

For a Web application, for example, there is a Kiosk Mode. Please see:
Running a Web Site in Kiosk Mode with C#[^].

—SA


已解决桌面问题

1)描述WinApi包装器
Solved with desktops

1) describe WinApi wrappers
[StructLayout(Sequental, Unicode)]
public struct SECURITY_ATTRIBUTES{     public Int32 nLength, SecurityDescriptor, bInheritHandle; }


描述对WinApi函数OpenDesktop,SwitchDesktop,SetThreadDesktop的引用


describe referenses to WinApi functions OpenDesktop, SwitchDesktop, SetThreadDesktop

[DllImport("user32.dll", Unicode)]
public static extern IntPtr CreateDesktop (string,string,Int32,UInt32,UInt32,IntPtr);



2)什么时候需要显示登录表单,
2a)创建登录桌面(如果存在,则仅打开)



2) when need to show Login Form,
2a) create login desktop (if it exists, it only open )

string dskName = "Logon desktop";
SECURITY_ATTRIBUTES sAtt = new SECURITY_ATTRIBUTES(){nLength=Marshal.SizeOf(typeof(SECURITY_ATTRIBUTES)), bInheritHandle=1};
sAtt.lpSecurityDescriptor =0;

IntPtr hglobal = Marshal.AllocHGlobal(Marshal.SizeOf(sAtt));
Marshal.StructureToPtr(sAtt, hglobal, false);

IntPtr logonDsk = CreateDesktop (dskName, null, 0, 1, 0x10000000, hglobal);

Marshal.FreeHGlobal(hglobal);



2b)创建新线程和登录表单



2b) create new thread and login form

Thread thread = new Thread(new ThreadStart(()=>
{
   logonDsk = createLoginDesk();
   SetThreadDesktop(logonDsk);
   SwitchDesktop(logonDsk);

loginForm = new LoginForm();
dlgResult = loginForm.ShowDialog();

var newdsk = OpenDesktop("Default",1,true,0x10000000);
SetThreadDesktop(newdsk);
SwitchDesktop(newdsk);
}));



3b)等待线程完成,然后从loginForm获取数据

附:解决方案将有更详细的说明.



3b) wait for finishing thread, after that get data from loginForm

p.s.: solution will be write in more details.


这篇关于如何在WinForm上创建安全的身份验证表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆