WindowsIdentity Constructor (IntPtr, String, WindowsAccountType)

Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token, the specified authentication type, and the specified Windows account type.

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

public:
WindowsIdentity (
	IntPtr userToken, 
	String^ type, 
	WindowsAccountType acctType
)
public WindowsIdentity (
	IntPtr userToken, 
	String type, 
	WindowsAccountType acctType
)
public function WindowsIdentity (
	userToken : IntPtr, 
	type : String, 
	acctType : WindowsAccountType
)

Parameters

userToken

The account token for the user on whose behalf the code is running.

type

The type of authentication used to identify the user.

acctType

One of the WindowsAccountType values.

Exception typeCondition

ArgumentException

userToken is 0.

-or-

userToken is duplicated and invalid for impersonation.

SecurityException

The caller does not have the correct permissions.

-or-

A Win32 error occurred.

The following table shows initial property values for an instance of WindowsIdentity.

Property

Initial Value

IsAuthenticated

false

NoteNote

The token represented by userToken is usually retrieved through a call to unmanaged code, such as a call to the Win32 API LogonUser function. For more information on calls to unmanaged code, see Consuming Unmanaged DLL Functions.

The following code shows the use of the WindowsIdentity constructor to create a new instance of the WindowsIdentity class for the user represented by the specified Windows account token, the specified authentication type, and the specified Windows account type. This code example is part of a larger example provided for the WindowsIdentity class.

String^ authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType::Guest;
WindowsIdentity^ windowsIdentity = gcnew WindowsIdentity( logonToken,authenticationType,guestAccount );


String authenticationType = "WindowsAuthentication";
WindowsAccountType guestAccount = WindowsAccountType.Guest;
WindowsIdentity windowsIdentity = new WindowsIdentity(logonToken,
    authenticationType, guestAccount);

Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: