Click here to Skip to main content
Rate this: bad
good
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
Comments
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
good
Please Sign up or sign in to vote.

Solution 2

class Program
    {
 
        [System.Runtime.InteropServices.DllImport("advapi32.dll")]
        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");
            Console.Read();
        }
 
        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;
        }
    }
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2014
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