I have a .NET 4.0 Winforms app. I’d like to require the user to re-enter his/her login password before using a sensitive feature. This needs to work for users logged in through Active Directory and through Windows Networking.
So I need to pop up a dialog box that contains the username and password fields, and OK and Cancel buttons.
I’m looking to see if there is maybe a dialog box like this built into windows. If not, I can design my own dialog box.
I believe I can determine the username using WindowsIdentity.GetCurrent().Name . Looks like the way to authenticate is by creating a PrincipalContext and calling ValidateCredentials() on it. Before creating the PrincipalContext, I need to know whether the user is authenticated through AD or Windows Networking, so I can construct PrincipalContext correctly. Maybe there is some piece of code that wraps up all of this in a neat call?
Microsoft has an article which describes how you can validate Windows user rights at support.micosoft.com.