Click here to Skip to main content
15,887,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hii friends
how to implement activedirectory with login page

please share to me code
Posted

You can google it, you will get lot of code for same.

For your ease, you can use below API

C#
[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 -
C#
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 -

C#
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
 
Share this answer
 

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