WindowsIdentity 构造函数

定义

初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class.

重载

WindowsIdentity(IntPtr)

为指定的 Windows 帐户标记表示的用户初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token.

WindowsIdentity(WindowsIdentity)

使用指定的 WindowsIdentity 对象初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class by using the specified WindowsIdentity object.

WindowsIdentity(String)

初始化以指定用户主名称 (UPN) 表示的用户的 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified User Principal Name (UPN).

WindowsIdentity(IntPtr, String)

为指定的 Windows 帐户标记和指定的身份验证类型表示的用户初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token and the specified authentication type.

WindowsIdentity(SerializationInfo, StreamingContext)

初始化 SerializationInfo 流中的信息所表示的用户的 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by information in a SerializationInfo stream.

WindowsIdentity(String, String)

初始化以指定用户主名称 (UPN) 和指定身份验证类型共同表示的用户的 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified User Principal Name (UPN) and the specified authentication type.

WindowsIdentity(IntPtr, String, WindowsAccountType)

为指定的 Windows 帐户标记、指定的身份验证类型和指定的 Windows 帐户类型表示的用户初始化 WindowsIdentity 类的新实例。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.

WindowsIdentity(IntPtr, String, WindowsAccountType, Boolean)

为指定的 Windows 帐户标记、指定的身份验证类型、指定的 Windows 帐户类型和指定的身份验证状态表示的用户初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token, the specified authentication type, the specified Windows account type, and the specified authentication status.

WindowsIdentity(IntPtr)

为指定的 Windows 帐户标记表示的用户初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token.

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

用户的帐户标记,代码当前即以该用户的名义运行。The account token for the user on whose behalf the code is running.

异常

userToken 为 0。userToken is 0.

-or- userToken 是重复的,对于模拟无效。userToken is duplicated and invalid for impersonation.

调用方没有正确的权限。The caller does not have the correct permissions.

- 或 --or-

出现 Win32 错误。A Win32 error occurred.

注解

下表显示了实例的WindowsIdentity初始属性值。The following table shows initial property values for an instance of WindowsIdentity.

PropertyProperty 初始值Initial value
AuthenticationType Negotiate
WindowsAccountType Normal
IsAuthenticated false

备注

可以userToken通过调用非托管代码(如 Windows API LogonUser函数)来检索表示的标记。You can retrieve the token represented by userToken by calling unmanaged code such as the Windows API LogonUser function. 始终通过userToken调用 Windows API CloseHandle函数进行发布。Always release userToken by calling the Windows API CloseHandle function. 有关调用非托管代码的详细信息,请参阅使用非托管 DLL 函数For more information on calling unmanaged code, see Consuming Unmanaged DLL Functions.

安全性

SecurityPermission
用于访问非托管代码的能力。for the ability to access unmanaged code. 关联枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode.

WindowsIdentity(WindowsIdentity)

使用指定的 WindowsIdentity 对象初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class by using the specified WindowsIdentity object.

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 新实例的对象。The object from which to construct the new instance of WindowsIdentity.

WindowsIdentity(String)

初始化以指定用户主名称 (UPN) 表示的用户的 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified User Principal Name (UPN).

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。The UPN for the user on whose behalf the code is running.

异常

Windows 返回 Windows NT 状态代码 STATUS_ACCESS_DENIED。Windows returned the Windows NT status code STATUS_ACCESS_DENIED.

没有足够的可用内存。There is insufficient memory available.

调用方没有正确的权限。The caller does not have the correct permissions.

-or-

计算机未连接到 Windows 2003 或更高版本的域。The computer is not attached to a Windows 2003 or later domain.

-or-

计算机没有运行 Windows 2003 或更高版本。The computer is not running Windows 2003 or later.

-or-

用户不是计算机所连接域的成员。The user is not a member of the domain the computer is attached to.

注解

UPN 的格式为用户名@domainname,即电子邮件地址。A UPN has the format username@domainname.com, in other words, an email address. sUserPrincipalName标识的 UPN 用于通过 Windows API LsaLogonUser函数检索该用户的令牌。The UPN identified in sUserPrincipalName is used to retrieve a token for that user through the Windows API LsaLogonUser function. 然后,令牌用于标识用户。In turn that token is used to identify the user. 由于无法使用所提供的 UPN 登录,可能会返回异常。An exception might be returned due to the inability to log on using the supplied UPN.

备注

此构造函数仅适用于加入到 Windows Server 2003 或更高版本的域的计算机。This constructor is intended for use only on computers joined to Windows Server 2003 or later domains. 对于早期域类型,将引发异常。An exception is thrown for earlier domain types. 此限制的原因是此构造函数使用的是 Windows Server 2003 中首次引入的KERB_S4U_LOGON 结构This restriction is due to the fact that this constructor uses the KERB_S4U_LOGON structure, which was first introduced in Windows Server 2003.

安全性

SecurityPermission
用于访问非托管代码的能力。for the ability to access unmanaged code. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode.

WindowsIdentity(IntPtr, String)

为指定的 Windows 帐户标记和指定的身份验证类型表示的用户初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token and the specified authentication type.

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

用户的帐户标记,代码当前即以该用户的名义运行。The account token for the user on whose behalf the code is running.

type
String

(仅供参考之用。)用于标识用户的身份验证的类型。(Informational use only.) The type of authentication used to identify the user.

异常

userToken 为 0。userToken is 0.

-or- userToken 是重复的,对于模拟无效。userToken is duplicated and invalid for impersonation.

调用方没有正确的权限。The caller does not have the correct permissions.

- 或 --or-

出现 Win32 错误。A Win32 error occurred.

示例

下面的代码演示如何使用WindowsIdentity构造函数为指定的 Windows 帐户标记和指定的身份验证类型表示的用户创建WindowsIdentity类的新实例。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 and the specified authentication type. 此代码示例是为WindowsIdentity类提供的更大示例的一部分。This code example is part of a larger example provided for the WindowsIdentity class.

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初始属性值。The following table shows initial property values for an instance of WindowsIdentity.

PropertyProperty 初始值Initial value
WindowsAccountType Normal
IsAuthenticated false

type参数的值用于AuthenticationType设置参数。The value of the type parameter is used to set the AuthenticationType parameter. 如果type AuthenticationTypenull,则安全系统将在Negotiate windows Vista Kerberos和更高版本的 windows 操作系统上将设置为,并在更早版本的 windows 操作系统上设置为。If type is null, the security system sets AuthenticationType to Negotiate on Windows Vista and later versions of the Windows operating system, and to Kerberos on earlier versions of the Windows operating system. 安全系统不使用此值;仅供参考。The security system does not use this value; it is for informational use only.

备注

可以userToken通过调用非托管代码(如 Windows API LogonUser函数)来检索表示的标记。You can retrieve the token represented by userToken by calling unmanaged code such as the Windows API LogonUser function. 始终通过userToken调用 Windows API CloseHandle函数进行发布。Always release userToken by calling the Windows API CloseHandle function. 有关调用非托管代码的详细信息,请参阅使用非托管 DLL 函数For more information on calling unmanaged code, see Consuming Unmanaged DLL Functions.

安全性

SecurityPermission
用于访问非托管代码的能力。for the ability to access unmanaged code. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode.

WindowsIdentity(SerializationInfo, StreamingContext)

初始化 SerializationInfo 流中的信息所表示的用户的 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by information in a SerializationInfo stream.

public:
 WindowsIdentity(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
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
Public Sub New (info As SerializationInfo, context As StreamingContext)

参数

info
SerializationInfo

包含用户帐户信息的对象。The object containing the account information for the user.

context
StreamingContext

指示流特征的对象。An object that indicates the stream characteristics.

异常

WindowsIdentity 无法跨进程序列化。A WindowsIdentity cannot be serialized across processes.

调用方没有正确的权限。The caller does not have the correct permissions.

-or-

出现 Win32 错误。A Win32 error occurred.

注解

重要

使用不受信任的数据调用此方法存在安全风险。Calling this method with untrusted data is a security risk. 仅使用受信任的数据调用此方法。Call this method only with trusted data. 有关详细信息,请参阅数据验证For more information, see Data Validation.

安全性

SecurityPermission
用于操作主体对象的能力。for ability to manipulate the principal object. 关联的枚举:ControlPrincipalAssociated enumeration: ControlPrincipal.

WindowsIdentity(String, String)

初始化以指定用户主名称 (UPN) 和指定身份验证类型共同表示的用户的 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified User Principal Name (UPN) and the specified authentication type.

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。The UPN for the user on whose behalf the code is running.

type
String

(仅供参考之用。)用于标识用户的身份验证的类型。(Informational use only.) The type of authentication used to identify the user.

异常

Windows 返回 Windows NT 状态代码 STATUS_ACCESS_DENIED。Windows returned the Windows NT status code STATUS_ACCESS_DENIED.

没有足够的可用内存。There is insufficient memory available.

调用方没有正确的权限。The caller does not have the correct permissions.

-or-

计算机未连接到 Windows 2003 或更高版本的域。The computer is not attached to a Windows 2003 or later domain.

-or-

计算机没有运行 Windows 2003 或更高版本。The computer is not running Windows 2003 or later.

-or-

用户不是计算机所连接域的成员。The user is not a member of the domain the computer is attached to.

注解

type参数的值用于AuthenticationType设置参数。The value of the type parameter is used to set the AuthenticationType parameter. 如果type AuthenticationTypenull,则安全系统将在Negotiate windows Vista Kerberos和更高版本的 windows 操作系统上将设置为,并在更早版本的 windows 操作系统上设置为。If type is null, the security system sets AuthenticationType to Negotiate on Windows Vista and later versions of the Windows operating system, and to Kerberos on earlier versions of the Windows operating system. 安全系统不使用此值;仅供参考。The security system does not use this value; it is for informational use only.

sUserPrincipalName标识的 UPN 用于通过 Windows API LsaLogonUser函数检索该用户的令牌。The UPN identified in sUserPrincipalName is used to retrieve a token for that user through the Windows API LsaLogonUser function. 然后,令牌用于标识用户。In turn that token is used to identify the user. 由于无法使用所提供的 UPN 登录,可能会返回异常。An exception might be returned due to the inability to log on using the supplied UPN.

备注

此构造函数仅适用于加入到 Windows Server 2003 或更高版本的域的计算机。This constructor is intended for use only on computers joined to Windows Server 2003 or later domains. 对于早期域类型,将引发异常。An exception is thrown for earlier domain types. 此限制的原因是此构造函数使用的是 Windows Server 2003 中首次引入的KERB_S4U_LOGON 结构This restriction is due to the fact that this constructor uses the KERB_S4U_LOGON structure, which was first introduced in Windows Server 2003.

安全性

SecurityPermission
用于访问非托管代码的能力。for the ability to access unmanaged code. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode.

WindowsIdentity(IntPtr, String, WindowsAccountType)

为指定的 Windows 帐户标记、指定的身份验证类型和指定的 Windows 帐户类型表示的用户初始化 WindowsIdentity 类的新实例。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.

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

用户的帐户标记,代码当前即以该用户的名义运行。The account token for the user on whose behalf the code is running.

type
String

(仅供参考之用。)用于标识用户的身份验证的类型。(Informational use only.) The type of authentication used to identify the user.

acctType
WindowsAccountType

枚举值之一。One of the enumeration values.

异常

userToken 为 0。userToken is 0.

-or- userToken 是重复的,对于模拟无效。userToken is duplicated and invalid for impersonation.

调用方没有正确的权限。The caller does not have the correct permissions.

- 或 --or-

出现 Win32 错误。A Win32 error occurred.

示例

下面的代码演示如何使用WindowsIdentity构造函数为指定的 windows 帐户标记、指定的身份验证类型和指定的 windows 帐户类型表示的用户创建WindowsIdentity类的新实例。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. 此代码示例是为WindowsIdentity类提供的更大示例的一部分。This code example is part of a larger example provided for the WindowsIdentity class.

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初始属性值。The following table shows initial property values for an instance of WindowsIdentity.

PropertyProperty 初始值Initial Value
IsAuthenticated false

type参数的值用于AuthenticationType设置参数。The value of the type parameter is used to set the AuthenticationType parameter. 如果type AuthenticationTypenull,则安全系统将在Negotiate windows Vista Kerberos和更高版本的 windows 操作系统上将设置为,并在更早版本的 windows 操作系统上设置为。If type is null, the security system sets AuthenticationType to Negotiate on Windows Vista and later versions of the Windows operating system, and to Kerberos on earlier versions of the Windows operating system. 安全系统不使用此值;仅供参考。The security system does not use this value; it is for informational use only.

备注

可以userToken通过调用非托管代码(如 Windows API LogonUser函数)来检索表示的标记。You can retrieve the token represented by userToken by calling unmanaged code such as the Windows API LogonUser function. 始终通过userToken调用 Windows API CloseHandle函数进行发布。Always release userToken by calling the Windows API CloseHandle function. 有关调用非托管代码的详细信息,请参阅使用非托管 DLL 函数For more information on calling unmanaged code, see Consuming Unmanaged DLL Functions.

安全性

SecurityPermission
用于访问非托管代码的能力。for the ability to access unmanaged code. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode.

WindowsIdentity(IntPtr, String, WindowsAccountType, Boolean)

为指定的 Windows 帐户标记、指定的身份验证类型、指定的 Windows 帐户类型和指定的身份验证状态表示的用户初始化 WindowsIdentity 类的新实例。Initializes a new instance of the WindowsIdentity class for the user represented by the specified Windows account token, the specified authentication type, the specified Windows account type, and the specified authentication status.

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

用户的帐户标记,代码当前即以该用户的名义运行。The account token for the user on whose behalf the code is running.

type
String

(仅供参考之用。)用于标识用户的身份验证的类型。(Informational use only.) The type of authentication used to identify the user.

acctType
WindowsAccountType

枚举值之一。One of the enumeration values.

isAuthenticated
Boolean

true 指示用户已经过身份验证,否则为 falsetrue to indicate that the user is authenticated; otherwise, false.

异常

userToken 为 0。userToken is 0.

-or- userToken 是重复的,对于模拟无效。userToken is duplicated and invalid for impersonation.

调用方没有正确的权限。The caller does not have the correct permissions.

-or-

出现 Win32 错误。A Win32 error occurred.

示例

下面的代码演示如何使用WindowsIdentity构造函数创建WindowsIdentity类的新实例,该实例由指定的 Windows 帐户标记、指定的身份验证类型、指定的 windows 帐户类型和指定的身份验证状态。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, the specified Windows account type, and the specified authentication status. 此代码示例是为WindowsIdentity类提供的更大示例的一部分。This code example is part of a larger example provided for the WindowsIdentity class.

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设置参数。The value of the type parameter is used to set the AuthenticationType parameter. 如果type AuthenticationTypenull,则安全系统将在Negotiate windows Vista Kerberos和更高版本的 windows 操作系统上将设置为,并在更早版本的 windows 操作系统上设置为。If type is null, the security system sets AuthenticationType to Negotiate on Windows Vista and later versions of the Windows operating system, and to Kerberos on earlier versions of the Windows operating system. 安全系统不使用此值;仅供参考。The security system does not use this value; it is for informational use only.

可以userToken通过调用非托管代码(如 Windows API LogonUser函数)来检索表示的标记。You can retrieve the token represented by userToken by calling unmanaged code such as the Windows API LogonUser function. 始终通过userToken调用 Windows API CloseHandle函数进行发布。Always release userToken by calling the Windows API CloseHandle function. 有关调用非托管代码的详细信息,请参阅使用非托管 DLL 函数For more information on calling unmanaged code, see Consuming Unmanaged DLL Functions.

安全性

SecurityPermission
用于访问非托管代码的能力。for the ability to access unmanaged code. 关联的枚举:UnmanagedCodeAssociated enumeration: UnmanagedCode.

适用于