Click here to Skip to main content
11,922,641 members (57,122 online)
Rate this:
Please Sign up or sign in to vote.
I have a windows application I want to use windows authentication log in at the beginning of my application please help!
Posted 18-Jul-12 11:36am
Wes Aday 18-Jul-12 16:43pm
Help with what? You have not stated a problem!
Tadit Dash 18-Jul-12 16:47pm
Have you tried anything. Please post your codes by clicking on Improve question link.
Trak4Net 18-Jul-12 17:57pm
If you can give more detail to your design plan and what you would like to see happen that would be helpful. My first thought is why? If the user is logged into the computer they are already authenticated. Are you trying to limit allowed users by comparing to user list stored in your application somewhere? Are you trying to lock your application after a period of no activity and hence require re-authenticaiton to unlock? There are many design scenarios and different ways to "validate" windows login, it all depends on what your design requires, so definitely give more in depth detail to what you are looking for.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

class Program
        public static extern bool LogonUser(string userName, string domainName, string password, int LogonType, int LogonProvider,ref IntPtr phToken);
        static void Main(string[] args)
            Program obj = new Program();
            bool isValid = obj.IsValidateCredentials("myUserName","MyPassword","MyDomain");
            Console.WriteLine(isValid == true ? "Valid User details" : "Invalid User Details");
        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;
Rate this: bad
Please Sign up or sign in to vote.

Solution 1


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web04 | 2.8.151125.1 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100