Token Property

WindowsIdentity.Token Property

 

Gets the Windows account token for the user.

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

Public Overridable ReadOnly Property Token As IntPtr

Property Value

Type: System.IntPtr

The handle of the access token associated with the current execution thread.

Do not explicitly release the account token that is returned by the Token property. The token is released by the Dispose method, which you can call in code. Dispose is also automatically called by the garbage collector.

System_CAPS_noteNote

The account token that is returned by the Token property is a duplicate of the Windows token that is used to create the WindowsIdentity object and is automatically released by the .NET Framework. This is different from the account token (the userToken parameter for the constructor), which is used to create the WindowsIdentity object. userToken is a Windows account token that is created by a call to LogonUser and must be closed to avoid a memory leak.

The following code shows the use of the IsSystem property to get the Windows account token for the user. This code example is part of a larger example provided for the WindowsIdentity class.

Dim accountToken As IntPtr = WindowsIdentity.GetCurrent().Token

SecurityPermission

for the ability to access unmanaged code. Associated enumeration: SecurityPermissionFlag.UnmanagedCode.

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft