Environment.UserName 속성

정의

현재 스레드와 연결된 사용자의 사용자 이름을 가져옵니다.

public:
 static property System::String ^ UserName { System::String ^ get(); };
public static string UserName { get; }
static member UserName : string
Public Shared ReadOnly Property UserName As String

속성 값

현재 스레드와 연결된 사용자의 사용자 이름입니다.

예제

다음은 현재 스레드를 시작한 사용자의 사용자 이름을 표시하는 예제입니다.

// Sample for the Environment.UserName property
using System;

class Sample
{
    public static void Main()
    {
    Console.WriteLine();
//  <-- Keep this information secure! -->
    Console.WriteLine("UserName: {0}", Environment.UserName);
    }
}
// Sample for the Environment.UserName property
open System

//  <-- Keep this information secure! -->
printfn $"\nUserName: {Environment.UserName}"
' Sample for the Environment.UserName property
Class Sample
   Public Shared Sub Main()
      Console.WriteLine()
      '  <-- Keep this information secure! -->
      Console.WriteLine("UserName: {0}", Environment.UserName)
   End Sub
End Class

설명

이 속성을 사용하여 UserName 보안 또는 액세스 목적으로 시스템 및 애플리케이션에 대한 현재 스레드의 사용자를 식별할 수 있습니다. 또한 각 사용자에 대해 특정 애플리케이션을 사용자 지정하는 데 사용할 수 있습니다.

Windows UserName 속성은 Windows GetUserName 함수에 대한 호출을 래핑합니다. 사용자의 도메인 계정 자격 증명은 사용자의 도메인 이름, '\' 문자 및 사용자 이름으로 형식이 지정됩니다. 속성을 UserDomainName 사용하여 사용자의 도메인 이름과 UserName 속성을 가져와서 사용자 이름을 가져옵니다.

Unix 플랫폼에서 속성은 UserName 함수에 대한 호출을 getpwuid_r 래핑합니다.

ASP.NET 애플리케이션이 개발 환경에서 실행되는 경우 UserName 속성은 현재 사용자의 이름을 반환합니다. 게시된 ASP.NET 애플리케이션에서 이 속성은 애플리케이션 풀 계정의 이름(예: 기본 AppPool)을 반환합니다.

적용 대상

추가 정보