Using Windows login credential in C# Application
-
i am developing a Desktop Application in c# where user have to give username and password to login. This application runs when windows starts. Now user have to give password for login to windows and then again the have to login in my application. My question is is there any option to get the login credential so that user have to login once for windows and my application? Thanks in advance.
-
i am developing a Desktop Application in c# where user have to give username and password to login. This application runs when windows starts. Now user have to give password for login to windows and then again the have to login in my application. My question is is there any option to get the login credential so that user have to login once for windows and my application? Thanks in advance.
You are saying that the user logging into Windows is, by default, the same one logging into your application at start-up? So why bother logging them in at all? Assume it is the same user and start your application. Unless you have another reason for tracking who is logged in to your application? Then you could use one of these or similar:
Environment.UserName
System.Windows.Forms.SystemInformation.UserName
me, me, me "The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!" Larry Niven nils illegitimus carborundum
-
You are saying that the user logging into Windows is, by default, the same one logging into your application at start-up? So why bother logging them in at all? Assume it is the same user and start your application. Unless you have another reason for tracking who is logged in to your application? Then you could use one of these or similar:
Environment.UserName
System.Windows.Forms.SystemInformation.UserName
me, me, me "The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!" Larry Niven nils illegitimus carborundum
-
i am developing a Desktop Application in c# where user have to give username and password to login. This application runs when windows starts. Now user have to give password for login to windows and then again the have to login in my application. My question is is there any option to get the login credential so that user have to login once for windows and my application? Thanks in advance.
You could check to see if the currently logged-in user is part of a particular group, and if so, just let them use the program. Otherwise, make them enter a password.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
one user can logout at any time from Application without loogin off from windows. and other user have to login into the application before the use the particular machine. so i have to keep separate user database form my application.
montosen wrote:
one user can logout at any time from Application without loogin off from windows
Then there's absolutely no way to use the current windows login info for anything beyond retrieving the currently logged-in user. If anothger user can come along and start using apps on another user's logon credentials, the app MUST ask for user ID and password.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001 -
montosen wrote:
one user can logout at any time from Application without loogin off from windows
Then there's absolutely no way to use the current windows login info for anything beyond retrieving the currently logged-in user. If anothger user can come along and start using apps on another user's logon credentials, the app MUST ask for user ID and password.
.45 ACP - because shooting twice is just silly
-----
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001