Check User Authentication Programmatically

Introduction=========

Many often it is required to check user authentication programmatically. Suppose you want to create a UI for taking user input of User ID and Password. Based on that UserID and password, Your windows service will run. So when user input userid and password then you must authenticate before store that information.

Solution======

So far no direct Donet framework(upto 3.5 sp1) component available for check user authentication programmatically. So you need to take help from windows api for that service.

The following code can capable to authenticate both local or domain account.

How Windows API help you====================

In "advapi32.dll" contain a function name "LogonUser". That function will help you to authenticate user programmatically.

To use that function you need to declare 2 enumaration named "LogonSessionType" and "LogonProvider"