2

First of all I did a google research on this but I haven't found a classy/stable solution yet.

I am currently on windows 7. The idea is to use that us all very famous windows authentication dialog and its background logic to let the windows confirm whether you are allowed.

I was hoping there would be something like this:

using(System.Credentials.WindowsAuthDialog dlg = new ...())
{
   // idk something like this
   if(dlg.Confirm() == Result.OK)
   {
      var user = dlg.authentificatedUser;
      string firstName = user.Firstname 
      ...
   }
}

Am I asking for too much? How shall I "correctly" use windows credentials dialog? Please provide me your experiences and examples. Thanks in advance guys

EDIT:

I am asking for that small dialog which pops up when you for example want to run an exe as admin. You have to provide your username and password. After that windows runs its background logic, connects to server or whatever and tells if you are allowed to do so.

dev hedgehog
  • 8,698
  • 3
  • 28
  • 55
  • What dialog do you mean? You have to be logged into Windows and authenticated to start any applications, so what exactly are you trying to log into? – Tim Rogers May 22 '15 at 08:49
  • @TimRogers I think he is talking about the UAC prompt that asks for admin username and password to access certain functionality – Inept Adept May 22 '15 at 08:56
  • Dialog which pops up when you want to run an exe as admin for example – dev hedgehog May 22 '15 at 09:02
  • Do you mean http://stackoverflow.com/questions/4134882/show-authentication-dialog-in-c-sharp-for-windows-vista-7 or http://stackoverflow.com/questions/10617337/how-to-show-windows-login-dialog? – Roger Lipscombe May 22 '15 at 09:05
  • I checked those two already a while ago but they seem so hacky. I would rather like to be sure that my code will always pick the right dialog instead of worring whether i am on windows xp, windows 7 or windows 10 – dev hedgehog May 22 '15 at 09:16
  • If you read the article it specifies one of them is specifically for vista and up, and if you are that worried do an os check before you show the relvant dialog – Inept Adept May 22 '15 at 09:23
  • what check should i implement for windows 10? – dev hedgehog May 22 '15 at 09:33

1 Answers1

0

I assume you mean this window

enter image description here

Searching StackOverflow I found the following article

UAC-style elevated prompt

So by the looks of it you can hook into the relevant API's but the amount of work required to replicate the UAC form and authentication

The best idea maybe to style a form like one and use your own logic or the API

And then have authorisation on certain methods based on the users Active Directory credentials

Community
  • 1
  • 1
Inept Adept
  • 414
  • 4
  • 11