5

How can we use WindowsIdentity in .NET Core 2.1?

It was available in 2.0

.NET API Browser

Rookian
  • 19,841
  • 28
  • 110
  • 180
  • "It was available in 2.0", so what happened to it? Check which packages you have installed and what was updated. Maybe you inadvertently uninstalled it? https://www.nuget.org/packages/System.Security.Principal.Windows/ – Camilo Terevinto Jun 04 '18 at 17:52
  • @CamiloTerevinto I didn't inadvertently uninstalled it, but it seems like MS removed it from .NET Core 2.1 and put it into a nuget package. – Rookian Jun 04 '18 at 17:57
  • The NuGet package exists since 2014, it's not even close to a new one... That said, I cannot find anything stating they removed it from .NET Core itself: https://github.com/dotnet/core/blob/master/release-notes/2.1/api-diff/2.0-vs-2.1.md – Camilo Terevinto Jun 04 '18 at 18:01
  • @CamiloTerevinto Yes that was my question/confusion. .NET API Browser does not show it anymore. – Rookian Jun 04 '18 at 18:05
  • Yeah, I saw the update... I would suggest you to open a bug: https://github.com/dotnet/core/issues. Not a lot we can do here unfortunately – Camilo Terevinto Jun 04 '18 at 18:07
  • Can you not reference it from the dll? should be in `C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.0\System.Security.Principal.Windows.dll` (windows install) – Luke Hutton Jun 04 '18 at 18:45
  • Possible duplicate of [Why WindowsIdentity class is not visible in .NET Core](https://stackoverflow.com/questions/47776680/why-windowsidentity-class-is-not-visible-in-net-core) – Chris Petheram Apr 03 '19 at 10:19

1 Answers1

-3

You can find the current Windows username using: System.Environment.UserName.

Marius Stănescu
  • 3,603
  • 2
  • 35
  • 49