Environment.UserName 속성

정의

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

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

속성 값

String

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

예제

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

// Sample for the Environment::UserName property
using namespace System;
int main()
{
   Console::WriteLine();

   //  <-- Keep this information secure! -->
   Console::WriteLine( "UserName: {0}", Environment::UserName );
}
// 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)의 이름을 반환합니다.

적용 대상

추가 정보