DIGIT-ARC read-only archive · snapshot: July 23, 2026

Windows Authentication for desktop Application

10 posts · originally from https://geek.digit.in/community/threads/windows-authentication-for-desktop-application.104137/

G
garv84 Original post #1
Dec 11, 2008 at 2:51 PM
Hello everyone.I have a VS 2005 (C#) windows application.when i run the application i want to authenticate the current login username and password with possibly the windows LoginAPI.can any one help me with a C# code.

Multiple users will be using the same desktop to login to my .Net application. I don't want to force the users to log out of the desktop everytime there is a new user, as this will take a long time to relogin to windows.



Here is what I'm looking to do (Preferably in C# and NO web services):

Presente the user with a form to enter their username and password
Authenticate these users against a windows XP
Use the Authentication token returned from Windows XP for verification and validation.


Assumptions:

the users will have separate accounts setup on Windows XP.

Can neone suggest how to use the PromptForCredentials class to validate the user and prompt the PromptForCredentials dialog ..i have gone thro the msdn but its not clear actaully.Can neone tell me the namespace to be used.
dheeraj_kumar
Dec 11, 2008 at 6:19 PM
*msdn.microsoft.com/en-us/library/aa374731(VS.85).aspx

check out the topic "credentials"
G
garv84 #3
Dec 11, 2008 at 9:08 PM
I have created the CredenialsDialog.cs class file taking help from Msdn.on form load i am calling a Login() method which prompts the Credentials dialog prompt.that method needs to authenticate the system username and password.I need that method implementation. private static bool Authenticate(string name, string password) {... }C# code.
dheeraj_kumar
Dec 12, 2008 at 2:42 AM
*www.developerfusion.com/code/4693/using-the-credential-management-api/
*www.google.com/search?client=opera...+api&sourceid=opera&num=100&ie=utf-8&oe=utf-8
G
garv84 #5
Dec 12, 2008 at 11:02 AM
Thanks for the links Dheeraj..!!

with ref to the link :

*www.developerfusion.com/code/4693/using-the-credential-management-api/2/


the Authentication via the loginAPI should be an internal process or i will have to write the code for authenticating the username and passowrd in the API that is provided by the windows users..

Code:
private static bool Authenticate(string name, string password)
{
// return true if the authentication succeeds
}

what will be the authntication code..?
dheeraj_kumar
Dec 12, 2008 at 3:24 PM
You have to write it on your own, I think.
G
garv84 #7
Dec 12, 2008 at 6:30 PM
Thats were the problem lies.If we were to write the autehntication method ourselves why on earth will we require the Windows "LoginAPI"..we could have implemented a simple form with two textboxes and two buttons.So whats the use..?
dheeraj_kumar
Dec 14, 2008 at 1:40 AM
Hmm... Is the credentials and the loginapi different stuff? Anyway, what exactly do you want to do? Perhaps we can find another way.
G
garv84 #9
Dec 15, 2008 at 2:22 PM
Hmm... Is the credentials and the loginapi different stuff? Anyway, what exactly do you want to do? Perhaps we can find another way.

As i told Dheeraj !! I have a Visual studio windows application.When i run the application i want a Username_password login Pop_up which will "Windows authenticate" the users.I mean to say that multiple users of the system can access the application without switching/logging off from the present user account(XP)

Is thre ne other way..?

Appreciating all your helps.
Thanks.
dheeraj_kumar
Dec 15, 2008 at 4:46 PM
Gotcha!

*blog.excastle.com/2004/11/05/api-magic-windows-password-dialog/
*groups.google.com/group/microsoft....ecurity/browse_thread/thread/ec793cda1bee7c7f

First link if you want to display the default windows password dialog, or just make your own if you feel thats complicated.
Second link has the stuff required to log-in to the comp.

Note that you need extensive reference with pinvoke.net as cred functions look awful :)

Hav fun :)