GenericIdentity Constructors
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the GenericIdentity class.
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. |
- Source:
- GenericIdentity.cs
- Source:
- GenericIdentity.cs
- Source:
- GenericIdentity.cs
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
.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 |
- Source:
- GenericIdentity.cs
- Source:
- GenericIdentity.cs
- Source:
- GenericIdentity.cs
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
.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 |
- 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.
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
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
.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 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: