Search code examples
wpfwindows.net-coreuser-accounts

Validate Local Windows Account Username and Password in .NET Core 3.1


I have a .NET Core 3.1 WPF app that I'm working on. In order to work with our older application it needs to validate credentials that are entered into a dialog for a local account. How can this be done?

It appears that all of the necessary classes have not been included in .NET Core yet, because the System.DirectoryServices package does not yet have the AccountManagement.PrincipalContext class that used to be used for this purpose.

Clarification

I have to validate creds for an arbitrary user account that may or may not be the account executing the app.


Solution

  • I hate to tell you, but the simple answer is that you can not. Interaction with active directory. There are limits on how integrated DNC 3.1 is - and you stumbled upon one. Supposedly dotnet 5.0 will better integrate.

    For now, you can either use win32 / native syntax for this, or use a server side proxy that handles the authentication.

    To my knowledge, you re requirements are simple not implemnented in the scope of the platform chosen.

    Anyone please feel free to correct me.

    Update: This is doable in .NET not core - so you can put up a smple website for this as service in .NET. So from the wpf side this turns into "make a http request".