GenericIdentity Constructors

Definition

Initializes a new instance of the GenericIdentity class.

Overloads

GenericIdentity(GenericIdentity)

Initializes a new instance of the GenericIdentity class by using the specified GenericIdentity object.

GenericIdentity(String)

Initializes a new instance of the GenericIdentity class representing the user with the specified name.

GenericIdentity(String, String)

Initializes a new instance of the GenericIdentity class representing the user with the specified name and authentication type.

GenericIdentity(GenericIdentity)

Initializes a new instance of the GenericIdentity class by using the specified GenericIdentity object.

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

Parameters

identity
GenericIdentity

The object from which to construct the new instance of GenericIdentity.

Applies to

GenericIdentity(String)

Initializes a new instance of the GenericIdentity class representing the user with the specified name.

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

Parameters

name
String

The name of the user on whose behalf the code is running.

Exceptions

The name parameter is null.

Examples

The following code shows the use of the GenericIdentity constructor. This code example is part of a larger example provided for the GenericIdentity class.

GenericIdentity^ defaultIdentity = gcnew GenericIdentity( "DefaultUser" );
GenericIdentity defaultIdentity = new GenericIdentity("DefaultUser");
Dim defaultIdentity As New GenericIdentity("DefaultUser")

Applies to

GenericIdentity(String, String)

Initializes a new instance of the GenericIdentity class representing the user with the specified name and authentication type.

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

Parameters

name
String

The name of the user on whose behalf the code is running.

type
String

The type of authentication used to identify the user.

Exceptions

The name parameter is null.

-or-

The type parameter is null.

Examples

The following code shows the use of the GenericIdentity constructor. This code example is part of a larger example provided for the GenericIdentity class.

WindowsIdentity^ windowsIdentity = WindowsIdentity::GetCurrent();

// Construct a GenericIdentity object based on the current Windows
// identity name and authentication type.
String^ authenticationType = windowsIdentity->AuthenticationType;
String^ userName = windowsIdentity->Name;
GenericIdentity^ authenticatedGenericIdentity = gcnew GenericIdentity( userName,authenticationType );
WindowsIdentity windowsIdentity = WindowsIdentity.GetCurrent();

// Construct a GenericIdentity object based on the current Windows
// identity name and authentication type.
string authenticationType = windowsIdentity.AuthenticationType;
string userName = windowsIdentity.Name;
GenericIdentity authenticatedGenericIdentity =
    new GenericIdentity(userName, authenticationType);
Dim windowsIdentity As WindowsIdentity = windowsIdentity.GetCurrent()

' Construct a GenericIdentity object based on the current Windows
' identity name and authentication type.
Dim authenticationType As String = windowsIdentity.AuthenticationType
Dim userName As String = windowsIdentity.Name
Dim authenticatedGenericIdentity As _
    New GenericIdentity(userName, authenticationType)

Applies to