Click here to Skip to main content
11,795,568 members (78,904 online)
Rate this: bad
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 10:36am
Wes Aday at 18-Jul-12 16:43pm
Help with what? You have not stated a problem!
Tadit Dash at 18-Jul-12 16:47pm
Have you tried anything. Please post your codes by clicking on Improve question link.
Trak4Net at 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
0 Maciej Los 340
1 Sergey Alexandrovich Kryukov 316
2 OriginalGriff 285
3 Abhinav S 223
4 KrunalRohit 214
0 OriginalGriff 1,797
1 Maciej Los 1,415
2 KrunalRohit 1,240
3 CPallini 840
4 ppolymorphe 808

Advertise | Privacy | Mobile
Web04 | 2.8.151002.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