Click here to Skip to main content
15,861,168 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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.
Posted
Updated 12-Apr-12 19:37pm
v2
Comments
Member 8810364 13-Apr-12 1:22am    
This application replace Explorer.exe and use autologon. It run authentication form and after authorization allow to run specialized application. It periodically ask user for input password. It allows to change user. When authentication form is running, other forms must be hidden.
Member 8810364 13-Apr-12 1:27am    
This application can't use Active Directory and standart windows authentication.

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.

[EDIT]

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
 
Share this answer
 
v2
Comments
Member 8810364 13-Apr-12 1:13am    
Ctrl+Alt+Del was disabled by local security policy (GPO)
Sergey Alexandrovich Kryukov 13-Apr-12 18:27pm    
This is not the only thing. You won't be able to disable activating another application window.
--SA
Solved with desktops

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

describe referenses to WinApi functions OpenDesktop, SwitchDesktop, SetThreadDesktop
C#
[DllImport("user32.dll", Unicode)]
public static extern IntPtr CreateDesktop (string,string,Int32,UInt32,UInt32,IntPtr);


2) when need to show Login Form,
2a) create login desktop (if it exists, it only open )
C#
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) create new thread and login form
C#
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) wait for finishing thread, after that get data from loginForm

p.s.: solution will be write in more details.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900