Sonderwoods
Sonderwoods

Reputation: 11

Finding Windows network first name and surnames in .NET 7.0 using C#

On our company network, Windows user names are like DomainXX\U12312, however our Windows accounts have actual names and surnames attached to them.

In my previous .NET Framework 4.6 projects, I could use System.DirectoryServies.AccountManagement as in the answer below:

Get Windows User Display Name

However, when converting to .NET 7-windows and adding System.DirectoryServices.AccountManagement (8.0.0, which should be compatible), every single property is throwing a PlatformNotSupportedException.

What could an alternative route be to obtain actual Windows first name and surname?

I've read other replies that updating System.DirectoryServies.AccountManagement to match target framework and also make sure that target framework has the -windows suffix

<TargetFramework>net7.0-windows</TargetFramework>

however this is not solving anything

Upvotes: 0

Views: 54

Answers (1)

Gabriel Luci
Gabriel Luci

Reputation: 40988

This GitHub issue says that it's just not supported in UWP projects, so if your project is UWP, it's just not possible.

If it's not a UWP project, you can try adding the Microsoft.Windows.Compatibility NuGet package.

Upvotes: 1

Related Questions