简体   繁体   中英

How can I get the current computer´s domain via asp.net core?

In .NET 4.7.2 I can get the current computer domain

using System.DirectoryServices.ActiveDirectory;

using (var lDomain = Domain.GetComputerDomain())
{
    [...]
}

How can I get the current computer´s domain via asp.net core?

According to your description, I suggest you could try to use IPGlobalProperties to get your current domain.

It provides information about the.network connectivity of the local computer.

      var re =   System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().DomainName;

Result:

在此处输入图像描述

Based on some searches, you should be able to install https://www.nuget.org/packages/System.DirectoryServices and use that class.

In .NET Core these classes are not part of the framework, requiring you to install Nuget packages for them.

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