This documentation is archived and is not being maintained.

Domain.GetComputerDomain Method

Gets the Domain object that represents the domain to which the local computer is joined.

Namespace:  System.DirectoryServices.ActiveDirectory
Assembly:  System.DirectoryServices (in System.DirectoryServices.dll)

public static Domain GetComputerDomain()

Return Value

Type: System.DirectoryServices.ActiveDirectory.Domain
A Domain object that represents the domain to which the local machine is joined.

ExceptionCondition
ActiveDirectoryObjectNotFoundException

A connection to the domain could not be made.

The return value of the GetComputerDomain method is a Domain object representing the domain to which the computer running the application is joined. This return value is independent of the domain credentials under which the application is run. This method will retrieve the computer's domain regardless of the trusted account domain credentials it is run under. To retrieve the Domain object that represents the domain corresponding to the user credentials in effect for the security context under which the application is running, use the GetCurrentDomain method instead.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: