954,580 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Authenticating a user by validating credentials against WIND NT server user/pwd

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!!

deeptim
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

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

[COde[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);[/COde]

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.

deeptim
Newbie Poster
2 posts since Aug 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You