You can google it, you will get lot of code for same.
For your ease, you can use below API
[DllImport("advapi32.dll", SetLastError = true)]
public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword,
int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
You need to use Enumeration to call API -
public enum Logon32Type
{
LOGON32_LOGON_INTERACTIVE = 2,
LOGON32_LOGON_NETWORK = 3,
LOGON32_LOGON_BATCH = 4,
LOGON32_LOGON_SERVICE = 5,
LOGON32_LOGON_UNLOCK = 7,
LOGON32_LOGON_NETWORK_CLEARTEXT = 8,
LOGON32_LOGON_NEW_CREDENTIALS = 9
}
public enum Logon32Provider
{
LOGON32_PROVIDER_DEFAULT = 0,
LOGON32_PROVIDER_WINNT35 = 1,
LOGON32_PROVIDER_WINNT40 = 2,
LOGON32_PROVIDER_WINNT50 = 3
}
Final Call -
IntPtr tokenHandle = new IntPtr(0);
bool isAuthenticate = LogonUser(userName, domainName, password,
(long)Logon32Type.LOGON32_LOGON_NETWORK, (long)Logon32Provider.LOGON32_PROVIDER_WINNT40,
ref tokenHandle);
Reference :
You also need to know what version of OS installed, you will get this from below link.
http://support.microsoft.com/kb/304283[
^]
-- Thanks Rushi