Click here to Skip to main content
13,049,814 members (71,541 online)
Rate this:
Please Sign up or sign in to 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 12-Apr-12 15:44pm
Updated 12-Apr-12 19:37pm
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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#[^].

Member 8810364 13-Apr-12 1:13am
Ctrl+Alt+Del was disabled by local security policy (GPO)
SAKryukov 13-Apr-12 18:27pm
This is not the only thing. You won't be able to disable activating another application window.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Solved with desktops

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

describe referenses to WinApi functions OpenDesktop, SwitchDesktop, SetThreadDesktop
[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 )
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);

2b) create new thread and login form
Thread thread = new Thread(new ThreadStart(()=>
   logonDsk = createLoginDesk();
loginForm = new LoginForm();
dlgResult = loginForm.ShowDialog();
var newdsk = OpenDesktop("Default",1,true,0x10000000);

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

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 19 Apr 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100