User.Name 속성
정의
현재 사용자의 이름을 가져옵니다.Gets the name of the current user.
public:
property System::String ^ Name { System::String ^ get(); };
public string Name { get; }
member this.Name : string
Public ReadOnly Property Name As String
속성 값
String
.String
. 현재 사용자의 이름입니다.The name of the current user.
예제
이 예제에서는 애플리케이션 Windows 또는 사용자 지정 인증을 사용 하 고 해당 정보를 사용 하 여 구문 분석 하 여 My.User.Name
속성입니다.This example checks if the application is using Windows or custom authentication, and uses that information to parse the My.User.Name
property.
Function GetUserName() As String
If TypeOf My.User.CurrentPrincipal Is
Security.Principal.WindowsPrincipal Then
' The application is using Windows authentication.
' The name format is DOMAIN\USERNAME.
Dim parts() As String = Split(My.User.Name, "\")
Dim username As String = parts(1)
Return username
Else
' The application is using custom authentication.
Return My.User.Name
End If
End Function
설명
사용할 수는 My.User
현재 사용자에 대 한 정보를 가져올 개체입니다.You can use the My.User
object to get information about the current user.
사용자를 인증 하는 보안 주체의 사용자 이름 형식을 제어 합니다.The principal that authenticates the user also controls the format of the user name. 기본적으로 애플리케이션에서 Windows 인증을 사용 하 고 사용자 이름이 도메인 \ 사용자 이름 형식입니다.By default, an application uses Windows authentication, and the user name has the format DOMAIN\USERNAME. 사용자의 사용자 지정 구현을 동일한 형식으로 반드시 사용 하지 않습니다.A custom implementation of the principal does not necessarily use the same format.
참고
정확한 동작을 My.User
애플리케이션이 실행 되는 운영 체제와 애플리케이션의 유형에 따라 개체에 따라 달라 집니다.The exact behavior of the My.User
object depends on the type of the application and on the operating system on which the application runs. 자세한 내용은 참조는 User 클래스 개요입니다.For more information, see the User class overview.
프로젝트 형식에 따라 가용성Availability by Project Type
프로젝트 형식Project type | 사용 가능Available |
---|---|
Windows 애플리케이션Windows Application | 예Yes |
클래스 라이브러리Class Library | 예Yes |
콘솔 애플리케이션Console Application | 예Yes |
Windows 컨트롤 라이브러리Windows Control Library | 예Yes |
웹 컨트롤 라이브러리Web Control Library | 예Yes |
Windows 서비스Windows Service | 예Yes |
웹 사이트Web Site | 예Yes |