Hi,

ASP .net is totally new area for me.
I am trying to build one web application to be accessed internally by my team through local network.
So, I am trying to add one login page in my project asking for user's username and pwd. Now, I want my application to validate the credentials provided by user against his id/pwd maintained by Windows NT domain.
Can someone help me with this and it would be nice if I could get detailed solution in steps.

Thanks!!

The solution for this requirement is to use Win32 API LogonUser.
To add following in the class:

[DllImport("ADVAPI32.dll", EntryPoint = "LogonUserW", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

and in Button's click event, need to add following:

protected void Button1_Click(object sender, EventArgs e)
    {
        IntPtr token = IntPtr.Zero;
        bool result = LogonUser(txtUser.Text, txtDomain.Text, txtPassword.Text, 2, 0, ref token);

        if (result)
        {
//            Response.Write("User Authenticated.");
            Response.Redirect("Welcome_Page.aspx");
        }
        else
        {
            Label2.Text="Invalid User, not authenicated. Please try again.";
        }

Hope it helps someone.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.