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)

Source:
GenericIdentity.cs
Source:
GenericIdentity.cs
Source:
GenericIdentity.cs

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

C#
protected GenericIdentity(System.Security.Principal.GenericIdentity identity);

Parameters

identity
GenericIdentity

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

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

GenericIdentity(String)

Source:
GenericIdentity.cs
Source:
GenericIdentity.cs
Source:
GenericIdentity.cs

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

C#
public GenericIdentity(string name);

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.

C#
GenericIdentity defaultIdentity = new GenericIdentity("DefaultUser");

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0

GenericIdentity(String, String)

Source:
GenericIdentity.cs
Source:
GenericIdentity.cs
Source:
GenericIdentity.cs

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

C#
public GenericIdentity(string name, string type);

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.

C#
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);

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1
UWP 10.0