简体   繁体   中英

.net core System.DirectoryServices not available?

I'm creating a project targetting dotnetcore 2.0.

According to the MSDN, System.DirectoryServices.ActiveDirectory should be usable in .net core 2.0 but I get an error that it can't find DirectoryServices under System.

The method I need is GetComputerDomain()

Is their an alternative for .net core 2.0?

I'm looking for an alternative to

using System.DirectoryServices.ActiveDirectory

var domain = Domain.GetComputerDomain();

??

WOuld like to be able to get the domain on windows and linux machines.

You need to refer System.DirectoryServices manually in your project.
Here is the MSDN link about managing references .

System.DirectoryServices is now available in .net core 2.1; however, it works fine in Windows, but not in Linux (throws PlatformNotSupportedException, not sure whether it's an expected behavior).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM