Windows Authentication for winforms with Windows 2000

Posted by The King on Stack Overflow See other posts from Stack Overflow or by The King
Published on 2010-05-26T14:03:03Z Indexed on 2010/05/26 14:11 UTC
Read the original article Hit count: 476

I use the following code to validate users through windows authentication for my winform application. This works fine with windows XP but when the user is using windows 2000, it says that the userid or password is in valid.

How do I do this in Windows 2000. Further, How do I detect whether the user is using Windows Xp or windows 2000.

        [System.Runtime.InteropServices.DllImport("advapi32.dll")]
    public static extern bool LogonUser(string userName, string domainName, string password, int LogonType, int LogonProvider, ref IntPtr phToken);

    public bool IsValidateCredentials(string userName, string password, string domain)
    {
        IntPtr tokenHandler = IntPtr.Zero;
        bool isValid = LogonUser(userName, domain, password, 2, 0, ref tokenHandler);
        return isValid;
    }

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms