Freigeben über


Environment.UserDomainName-Eigenschaft

Ruft den Netzwerkdomänennamen ab, der dem aktuellen Benutzer zugeordnet ist.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared ReadOnly Property UserDomainName As String
'Usage
Dim value As String

value = Environment.UserDomainName
public static string UserDomainName { get; }
public:
static property String^ UserDomainName {
    String^ get ();
}
/** @property */
public static String get_UserDomainName ()
public static function get UserDomainName () : String

Eigenschaftenwert

Der Netzwerkdomänenname des Hostcomputers.

Ausnahmen

Ausnahmetyp Bedingung

PlatformNotSupportedException

Das Betriebssystem unterstützt das Abrufen des Netzwerkdomänennamens nicht.

InvalidOperationException

Der Netzwerkdomänenname kann nicht abgerufen werden.

Hinweise

Die UserDomainName-Eigenschaft versucht zunächst, die Domänennamenkomponente des Windows NT 4.0-Kontonamens für den aktuellen Benutzer abzurufen. Der Kontoname wird als Domänenname, das "\"-Zeichen und Benutzername formatiert. Wenn bei dem Versuch ein Fehler auftritt, versucht diese Eigenschaft den Domänennamen abzurufen, der dem durch die UserName-Eigenschaft bereitgestellten Benutzernamen zugeordnet ist. Wenn bei diesem Versuch ein Fehler auftritt, weil der Hostcomputer kein Mitglied einer Domäne ist, wird der Name des Hostcomputers zurückgegeben.

Hinweis zu Windows 95, Windows 98, Windows 98 Zweite Ausgabe, Windows Millennium Edition: Die UserDomainName-Eigenschaft wird für dieses Plattform nicht unterstützt.

Beispiel

Im folgenden Codebeispiel wird der Benutzerdomänenname des Computers angezeigt, auf dem das Codebeispiel ausgeführt wird. (Der Benutzerdomänenname wird in der Ausgabe des Codebeispiels aus Sicherheitsgründen weggelassen.)

' Sample for the Environment.UserDomainName property
Imports System

Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      '  <-- Keep this information secure! -->
      Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'(Any result that is lengthy, specific to the machine on which this sample was tested, 
'or reveals information that should remain secure, has been omitted 
'and marked "!---OMITTED---!".)
'
'UserDomainName: !---OMITTED---!
'
// Sample for the Environment.UserDomainName property
using System;

class Sample 
{
    public static void Main() 
    {
    Console.WriteLine();
//  <-- Keep this information secure! -->
    Console.WriteLine("UserDomainName: {0}", Environment.UserDomainName);
    }
}
/*
This example produces the following results:
(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked "!---OMITTED---!".)

UserDomainName: !---OMITTED---!
*/
// Sample for the Environment::UserDomainName property
using namespace System;
int main()
{
   Console::WriteLine();
   
   //  <-- Keep this information secure! -->
   Console::WriteLine( "UserDomainName: {0}", Environment::UserDomainName );
}

/*
This example produces the following results:
(Any result that is lengthy, specific to the machine on which this sample was tested, or reveals information that should remain secure, has been omitted and marked S"!---OMITTED---!".)

UserDomainName: !---OMITTED---!
*/
// Sample for the Environment.UserDomainName property

import System.*;

class Sample
{
    public static void main(String[] args)
    {
        Console.WriteLine();
        //  <-- Keep this information secure! -->
        Console.WriteLine("UserDomainName: {0}", 
            Environment.get_UserDomainName());
    } //main
} //Sample

/*
This example produces the following results:
(Any result that is lengthy, specific to the machine on which this sample was 
 tested, or reveals information that should remain secure, has been omitted 
 and marked "!---OMITTED---!".)

UserDomainName: !---OMITTED---!
*/

.NET Framework-Sicherheit

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Environment-Klasse
Environment-Member
System-Namespace