WindowsIdentity 생성자

정의

WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

오버로드

WindowsIdentity(IntPtr)

지정된 Windows 계정 토큰이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(WindowsIdentity)

지정된 WindowsIdentity 개체를 사용하여 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(String)

지정된 UPN(사용자 계정 이름)이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(IntPtr, String)

지정된 Windows 계정 토큰 및 지정된 인증 형식이 나타내는 사용자에 대한 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(SerializationInfo, StreamingContext)
사용되지 않음.

WindowsIdentity 스트림의 정보가 나타내는 사용자에 대해 SerializationInfo 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(String, String)

지정된 UPN(사용자 계정 이름) 및 지정된 인증 형식이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(IntPtr, String, WindowsAccountType)

지정된 Windows 계정 토큰, 지정된 인증 형식 및 지정된 Windows 계정 유형이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(IntPtr, String, WindowsAccountType, Boolean)

지정된 Windows 계정 토큰, 지정된 인증 형식, 지정된 Windows 계정 유형 및 지정된 인증 상태가 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

WindowsIdentity(IntPtr)

지정된 Windows 계정 토큰이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

public:
 WindowsIdentity(IntPtr userToken);
public WindowsIdentity (IntPtr userToken);
new System.Security.Principal.WindowsIdentity : nativeint -> System.Security.Principal.WindowsIdentity
Public Sub New (userToken As IntPtr)

매개 변수

userToken
IntPtr

nativeint

코드를 실행하고 있는 사용자를 나타내는 계정 토큰입니다.

예외

userToken가 0입니다.

또는

userToken이 중복되었고 가장에 사용할 수 없는 경우

호출자에게 올바른 권한이 없습니다.

또는

Win32 오류가 발생한 경우

설명

다음 표에서 인스턴스에 대 한 초기 속성 값을 보여 줍니다. WindowsIdentity합니다.

속성 초기 값
AuthenticationType Negotiate
WindowsAccountType Normal
IsAuthenticated false

참고

Windows API LogonUser 함수와 같은 관리되지 않는 코드를 호출하여 가 userToken 나타내는 토큰을 검색할 수 있습니다. 항상 Windows API CloseHandle 함수를 호출하여 릴리스 userToken 합니다. 관리되지 않는 코드를 호출하는 방법에 대한 자세한 내용은 관리되지 않는 DLL 함수 소비를 참조하세요.

적용 대상

WindowsIdentity(WindowsIdentity)

지정된 WindowsIdentity 개체를 사용하여 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

protected:
 WindowsIdentity(System::Security::Principal::WindowsIdentity ^ identity);
protected WindowsIdentity (System.Security.Principal.WindowsIdentity identity);
new System.Security.Principal.WindowsIdentity : System.Security.Principal.WindowsIdentity -> System.Security.Principal.WindowsIdentity
Protected Sub New (identity As WindowsIdentity)

매개 변수

identity
WindowsIdentity

WindowsIdentity의 새 인스턴스를 만들 개체입니다.

적용 대상

WindowsIdentity(String)

지정된 UPN(사용자 계정 이름)이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

public:
 WindowsIdentity(System::String ^ sUserPrincipalName);
public WindowsIdentity (string sUserPrincipalName);
new System.Security.Principal.WindowsIdentity : string -> System.Security.Principal.WindowsIdentity
Public Sub New (sUserPrincipalName As String)

매개 변수

sUserPrincipalName
String

코드를 실행하고 있는 사용자의 UPN입니다.

예외

Windows에서 Windows NT 상태 코드 STATUS_ACCESS_DENIED를 반환했습니다.

사용 가능한 메모리가 부족한 경우

호출자에게 올바른 권한이 없습니다.

또는

Windows 2003 또는 높은 버전 도메인에 컴퓨터가 연결되어 있지 않습니다.

또는

컴퓨터가 Windows 2003 이상에서 실행되고 있지 않습니다.

또는

사용자는 컴퓨터에 연결된 도메인의 멤버가 아닙니다.

설명

UPN에는 usernamedomainname.com@ 형식, 즉 이메일 주소가 있습니다. 에서 sUserPrincipalName 식별된 UPN은 Windows API LsaLogonUser 함수를 통해 해당 사용자의 토큰을 검색하는 데 사용됩니다. 차례로 해당 토큰은 사용자를 식별하는 데 사용됩니다. 제공된 UPN을 사용하여 로그온할 수 없기 때문에 예외가 반환될 수 있습니다.

참고

이 생성자는 Windows Server 2003 이상 도메인에 가입된 컴퓨터에서만 사용할 수 있습니다. 이전 도메인 형식에 대해 예외가 throw됩니다. 이 제한은 이 생성자가 Windows Server 2003에서 처음 도입된 KERB_S4U_LOGON 구조를 사용하기 때문입니다. 또한 이 생성자에는 대상 사용자 계정의 token-groups-global-and-universal(TGGAU) 특성 에 대한 읽기 권한이 필요합니다.

적용 대상

WindowsIdentity(IntPtr, String)

지정된 Windows 계정 토큰 및 지정된 인증 형식이 나타내는 사용자에 대한 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

public:
 WindowsIdentity(IntPtr userToken, System::String ^ type);
public WindowsIdentity (IntPtr userToken, string type);
new System.Security.Principal.WindowsIdentity : nativeint * string -> System.Security.Principal.WindowsIdentity
Public Sub New (userToken As IntPtr, type As String)

매개 변수

userToken
IntPtr

nativeint

코드를 실행하고 있는 사용자를 나타내는 계정 토큰입니다.

type
String

(참조용으로만 사용) 사용자를 식별하는 데 사용되는 인증 형식입니다.

예외

userToken가 0입니다.

또는

userToken이 중복되었고 가장에 사용할 수 없는 경우

호출자에게 올바른 권한이 없습니다.

또는

Win32 오류가 발생한 경우

예제

다음 코드에서는 생성자를 사용하여 WindowsIdentity 지정된 Windows 계정 토큰 및 지정된 인증 유형으로 표시되는 사용자에 대한 클래스의 WindowsIdentity 새 instance 만드는 방법을 보여 있습니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 WindowsIdentity 클래스입니다.

void IntPtrStringConstructor( IntPtr logonToken )
{
   
   // Construct a WindowsIdentity object using the input account token 
   // and the specified authentication type.
   String^ authenticationType = "WindowsAuthentication";
   WindowsIdentity^ windowsIdentity = gcnew WindowsIdentity( logonToken,authenticationType );
   
   Console::WriteLine( "Created a Windows identity object named {0}.", windowsIdentity->Name );
}
private static void IntPtrStringConstructor(IntPtr logonToken)
{
    // Construct a WindowsIdentity object using the input account token 
    // and the specified authentication type.
    string authenticationType = "WindowsAuthentication";
    WindowsIdentity windowsIdentity =
                    new WindowsIdentity(logonToken, authenticationType);

    Console.WriteLine("Created a Windows identity object named " +
        windowsIdentity.Name + ".");
}
Private Sub IntPtrStringConstructor(ByVal logonToken As IntPtr)
    ' Construct a WindowsIdentity object using the input account token 
    ' and the specified authentication type
    Dim authenticationType = "WindowsAuthentication"
    Dim windowsIdentity As _
        New WindowsIdentity(logonToken, authenticationType)

    WriteLine("Created a Windows identity object named " + _
        windowsIdentity.Name + ".")
End Sub

설명

다음 표에서 인스턴스에 대 한 초기 속성 값을 보여 줍니다. WindowsIdentity합니다.

속성 초기 값
WindowsAccountType Normal
IsAuthenticated false

매개 변수의 type 값은 매개 변수를 설정하는 AuthenticationType 데 사용됩니다. 이 이면 type 보안 시스템은 Windows Vista 이상 버전의 Windows 운영 체제 및 이전 버전의 Windows 운영 Kerberos 체제에서 로 설정합니다 AuthenticationTypeNegotiate.null 보안 시스템은 이 값을 사용하지 않습니다. 정보 전용입니다.

참고

Windows API LogonUser 함수와 같은 관리되지 않는 코드를 호출하여 가 userToken 나타내는 토큰을 검색할 수 있습니다. 항상 Windows API CloseHandle 함수를 호출하여 릴리스 userToken 합니다. 관리되지 않는 코드를 호출하는 방법에 대한 자세한 내용은 관리되지 않는 DLL 함수 소비를 참조하세요.

적용 대상

WindowsIdentity(SerializationInfo, StreamingContext)

주의

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

WindowsIdentity 스트림의 정보가 나타내는 사용자에 대해 SerializationInfo 클래스의 새 인스턴스를 초기화합니다.

public:
 WindowsIdentity(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
public WindowsIdentity (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public WindowsIdentity (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.Principal.WindowsIdentity : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Principal.WindowsIdentity
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Principal.WindowsIdentity : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Principal.WindowsIdentity
Public Sub New (info As SerializationInfo, context As StreamingContext)

매개 변수

info
SerializationInfo

사용자에 대한 계정 정보가 포함된 개체입니다.

context
StreamingContext

스트림 특징을 나타내는 개체입니다.

특성

예외

WindowsIdentity가 둘 이상의 프로세스에 걸쳐 serialize될 수 없는 경우

호출자에게 올바른 권한이 없습니다.

또는

Win32 오류가 발생한 경우

설명

중요

신뢰할 수 없는 데이터로 이 메서드를 호출하는 것은 보안상 위험합니다. 신뢰할 수 있는 데이터로만 이 메서드를 호출하세요. 자세한 내용은 모든 입력 유효성 검사를 참조하세요.

적용 대상

WindowsIdentity(String, String)

지정된 UPN(사용자 계정 이름) 및 지정된 인증 형식이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

public:
 WindowsIdentity(System::String ^ sUserPrincipalName, System::String ^ type);
public WindowsIdentity (string sUserPrincipalName, string type);
new System.Security.Principal.WindowsIdentity : string * string -> System.Security.Principal.WindowsIdentity
Public Sub New (sUserPrincipalName As String, type As String)

매개 변수

sUserPrincipalName
String

코드를 실행하고 있는 사용자의 UPN입니다.

type
String

(참조용으로만 사용) 사용자를 식별하는 데 사용되는 인증 형식입니다.

예외

Windows에서 Windows NT 상태 코드 STATUS_ACCESS_DENIED를 반환했습니다.

사용 가능한 메모리가 부족한 경우

호출자에게 올바른 권한이 없습니다.

또는

Windows 2003 또는 높은 버전 도메인에 컴퓨터가 연결되어 있지 않습니다.

또는

컴퓨터가 Windows 2003 이상에서 실행되고 있지 않습니다.

또는

사용자는 컴퓨터에 연결된 도메인의 멤버가 아닙니다.

설명

매개 변수의 type 값은 매개 변수를 설정하는 AuthenticationType 데 사용됩니다. 이 이면 type 보안 시스템은 Windows Vista 이상 버전의 Windows 운영 체제 및 이전 버전의 Windows 운영 Kerberos 체제에서 로 설정합니다 AuthenticationTypeNegotiate.null 보안 시스템은 이 값을 사용하지 않습니다. 정보 전용입니다.

에서 sUserPrincipalName 식별된 UPN은 Windows API LsaLogonUser 함수를 통해 해당 사용자의 토큰을 검색하는 데 사용됩니다. 차례로 해당 토큰은 사용자를 식별하는 데 사용됩니다. 제공된 UPN을 사용하여 로그온할 수 없기 때문에 예외가 반환될 수 있습니다.

참고

이 생성자는 Windows Server 2003 이상 도메인에 가입된 컴퓨터에서만 사용할 수 있습니다. 이전 도메인 형식에 대해 예외가 throw됩니다. 이 제한은 이 생성자가 Windows Server 2003에서 처음 도입된 KERB_S4U_LOGON 구조를 사용하기 때문입니다. 또한 이 생성자에는 대상 사용자 계정의 token-groups-global-and-universal(TGGAU) 특성 에 대한 읽기 권한이 필요합니다.

적용 대상

WindowsIdentity(IntPtr, String, WindowsAccountType)

지정된 Windows 계정 토큰, 지정된 인증 형식 및 지정된 Windows 계정 유형이 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

public:
 WindowsIdentity(IntPtr userToken, System::String ^ type, System::Security::Principal::WindowsAccountType acctType);
public WindowsIdentity (IntPtr userToken, string type, System.Security.Principal.WindowsAccountType acctType);
new System.Security.Principal.WindowsIdentity : nativeint * string * System.Security.Principal.WindowsAccountType -> System.Security.Principal.WindowsIdentity
Public Sub New (userToken As IntPtr, type As String, acctType As WindowsAccountType)

매개 변수

userToken
IntPtr

nativeint

코드를 실행하고 있는 사용자를 나타내는 계정 토큰입니다.

type
String

(참조용으로만 사용) 사용자를 식별하는 데 사용되는 인증 형식입니다.

acctType
WindowsAccountType

열거형 값 중 하나입니다.

예외

userToken가 0입니다.

또는

userToken이 중복되었고 가장에 사용할 수 없는 경우

호출자에게 올바른 권한이 없습니다.

또는

Win32 오류가 발생한 경우

예제

다음 코드에서는 생성자를 사용하여 WindowsIdentity 지정된 Windows 계정 토큰, 지정된 인증 유형 및 지정된 Windows 계정 유형으로 표시되는 사용자에 대한 클래스의 WindowsIdentity 새 instance 만드는 방법을 보여 있습니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 WindowsIdentity 클래스입니다.

void IntPtrStringTypeConstructor( IntPtr logonToken )
{
   
   // Construct a WindowsIdentity object using the input account token,
   // and the specified authentication type and Windows account type.
   String^ authenticationType = "WindowsAuthentication";
   WindowsAccountType guestAccount = WindowsAccountType::Guest;
   WindowsIdentity^ windowsIdentity = gcnew WindowsIdentity( logonToken,authenticationType,guestAccount );
   
   Console::WriteLine( "Created a Windows identity object named {0}.", windowsIdentity->Name );
}
private static void IntPtrStringTypeConstructor(IntPtr logonToken)
{
    // Construct a WindowsIdentity object using the input account token,
    // and the specified authentication type, and Windows account type.
    string authenticationType = "WindowsAuthentication";
    WindowsAccountType guestAccount = WindowsAccountType.Guest;
    WindowsIdentity windowsIdentity =
        new WindowsIdentity(logonToken, authenticationType, guestAccount);

    Console.WriteLine("Created a Windows identity object named " +
        windowsIdentity.Name + ".");
}
Private Sub IntPtrStringTypeConstructor(ByVal logonToken As IntPtr)
    ' Construct a WindowsIdentity object using the input account token,
    ' and the specified authentication type and Windows account type.
    Dim authenticationType As String = "WindowsAuthentication"
    Dim guestAccount As WindowsAccountType = WindowsAccountType.Guest
    Dim windowsIdentity As _
        New WindowsIdentity(logonToken, authenticationType, guestAccount)

    WriteLine("Created a Windows identity object named " + _
        windowsIdentity.Name + ".")
End Sub

설명

다음 표에서 인스턴스에 대 한 초기 속성 값을 보여 줍니다. WindowsIdentity합니다.

속성 초기 값
IsAuthenticated false

매개 변수의 type 값은 매개 변수를 설정하는 AuthenticationType 데 사용됩니다. 이 이면 type 보안 시스템은 Windows Vista 이상 버전의 Windows 운영 체제 및 이전 버전의 Windows 운영 Kerberos 체제에서 로 설정합니다 AuthenticationTypeNegotiate.null 보안 시스템은 이 값을 사용하지 않습니다. 정보 전용입니다.

참고

Windows API LogonUser 함수와 같은 관리되지 않는 코드를 호출하여 가 userToken 나타내는 토큰을 검색할 수 있습니다. 항상 Windows API CloseHandle 함수를 호출하여 릴리스 userToken 합니다. 관리되지 않는 코드를 호출하는 방법에 대한 자세한 내용은 관리되지 않는 DLL 함수 소비를 참조하세요.

적용 대상

WindowsIdentity(IntPtr, String, WindowsAccountType, Boolean)

지정된 Windows 계정 토큰, 지정된 인증 형식, 지정된 Windows 계정 유형 및 지정된 인증 상태가 나타내는 사용자에 대해 WindowsIdentity 클래스의 새 인스턴스를 초기화합니다.

public:
 WindowsIdentity(IntPtr userToken, System::String ^ type, System::Security::Principal::WindowsAccountType acctType, bool isAuthenticated);
public WindowsIdentity (IntPtr userToken, string type, System.Security.Principal.WindowsAccountType acctType, bool isAuthenticated);
new System.Security.Principal.WindowsIdentity : nativeint * string * System.Security.Principal.WindowsAccountType * bool -> System.Security.Principal.WindowsIdentity
Public Sub New (userToken As IntPtr, type As String, acctType As WindowsAccountType, isAuthenticated As Boolean)

매개 변수

userToken
IntPtr

nativeint

코드를 실행하고 있는 사용자를 나타내는 계정 토큰입니다.

type
String

(참조용으로만 사용) 사용자를 식별하는 데 사용되는 인증 형식입니다.

acctType
WindowsAccountType

열거형 값 중 하나입니다.

isAuthenticated
Boolean

인증된 사용자이면 true이고, 그렇지 않으면 false입니다.

예외

userToken가 0입니다.

또는

userToken이 중복되었고 가장에 사용할 수 없는 경우

호출자에게 올바른 권한이 없습니다.

또는

Win32 오류가 발생한 경우

예제

다음 코드에서는 생성자를 사용하여 WindowsIdentity 지정된 Windows 계정 토큰, 지정된 인증 유형, 지정된 Windows 계정 유형 및 지정된 인증 상태 WindowsIdentity 나타내는 사용자에 대한 클래스의 새 instance 만드는 방법을 보여 있습니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 WindowsIdentity 클래스입니다.

void IntPrtStringTypeBoolConstructor( IntPtr logonToken )
{
   
   // Construct a WindowsIdentity object using the input account token,
   // and the specified authentication type, Windows account type, and
   // authentication flag.
   String^ authenticationType = "WindowsAuthentication";
   WindowsAccountType guestAccount = WindowsAccountType::Guest;
   bool isAuthenticated = true;
   WindowsIdentity^ windowsIdentity = gcnew WindowsIdentity( logonToken,authenticationType,guestAccount,isAuthenticated );
   
   Console::WriteLine( "Created a Windows identity object named {0}.", windowsIdentity->Name );
}
private static void IntPrtStringTypeBoolConstructor(IntPtr logonToken)
{
    // Construct a WindowsIdentity object using the input account token,
    // and the specified authentication type, Windows account type, and
    // authentication flag.
    string authenticationType = "WindowsAuthentication";
    WindowsAccountType guestAccount = WindowsAccountType.Guest;
    bool isAuthenticated = true;
    WindowsIdentity windowsIdentity = new WindowsIdentity(
        logonToken, authenticationType, guestAccount, isAuthenticated);

    Console.WriteLine("Created a Windows identity object named " +
        windowsIdentity.Name + ".");
}
Private Sub IntPrtStringTypeBoolConstructor(ByVal logonToken As IntPtr)
    ' Construct a WindowsIdentity object using the input account token,
    ' and the specified authentication type, Windows account type, and
    ' authentication flag.
    Dim authenticationType As String = "WindowsAuthentication"
    Dim guestAccount As WindowsAccountType = WindowsAccountType.Guest
    Dim isAuthenticated As Boolean = True
    Dim windowsIdentity As New WindowsIdentity( _
        logonToken, authenticationType, guestAccount, isAuthenticated)

    WriteLine("Created a Windows identity object named " + _
        windowsIdentity.Name + ".")
End Sub

설명

매개 변수의 type 값은 매개 변수를 설정하는 AuthenticationType 데 사용됩니다. 이 이면 type 보안 시스템은 Windows Vista 이상 버전의 Windows 운영 체제 및 이전 버전의 Windows 운영 Kerberos 체제에서 로 설정합니다 AuthenticationTypeNegotiate.null 보안 시스템은 이 값을 사용하지 않습니다. 정보 전용입니다.

Windows API LogonUser 함수와 같은 관리되지 않는 코드를 호출하여 가 userToken 나타내는 토큰을 검색할 수 있습니다. 항상 Windows API CloseHandle 함수를 호출하여 릴리스 userToken 합니다. 관리되지 않는 코드를 호출하는 방법에 대한 자세한 내용은 관리되지 않는 DLL 함수 소비를 참조하세요.

적용 대상