Definition
Assembly: System.Security.Claims.dll Namespace: System.Security.ClaimsSyntax
Summary
This type is defined in System.Security.Claims.Remarks
See Microsoft documentation for more information about the rest of the API.Methods
GetUserEmail Extension
Extension method from
System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensionsSyntax
Parameters
| Name | Type | Description |
|---|---|---|
principal | System.Security.Claims.ClaimsPrincipal | The claims principal to extract the email from. |
Returns
Type:string?
The user email, or null if not found.
Remarks
This method looks for the email in common claim types used by different authentication providers.GetUserId Extension
Extension method from
System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensionsSyntax
Parameters
| Name | Type | Description |
|---|---|---|
principal | System.Security.Claims.ClaimsPrincipal | The claims principal to extract the user ID from. |
Returns
Type:string?
The user identifier, or null if not found.
Remarks
This method looks for the user identifier in common claim types used by different authentication providers.GetUserName Extension
Extension method from
System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensionsSyntax
Parameters
| Name | Type | Description |
|---|---|---|
principal | System.Security.Claims.ClaimsPrincipal | The claims principal to extract the username from. |
Returns
Type:string?
The username, or null if not found.
Remarks
This method looks for the username in common claim types used by different authentication providers.GetUserRoles Extension
Extension method from
System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensionsSyntax
Parameters
| Name | Type | Description |
|---|---|---|
principal | System.Security.Claims.ClaimsPrincipal | The claims principal to extract roles from. |
Returns
Type:System.Collections.Generic.IEnumerable<string>
A collection of user roles, or empty if no roles are found.
Examples
Remarks
This method looks for roles in various claim types commonly used by different authentication providers. Roles can be in individual claims or comma-separated values.GetUserScopes Extension
Extension method from
System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensionsSyntax
Parameters
| Name | Type | Description |
|---|---|---|
principal | System.Security.Claims.ClaimsPrincipal | The claims principal to extract scopes from. |
Returns
Type:System.Collections.Generic.IEnumerable<string>
A collection of user scopes, or empty if no scopes are found.
Examples
Remarks
This method looks for scopes in various claim types commonly used by different authentication providers. Scopes are typically space-separated values in a single claim.HasRole Extension
Extension method from
System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensionsSyntax
Parameters
| Name | Type | Description |
|---|---|---|
principal | System.Security.Claims.ClaimsPrincipal | The claims principal to check. |
role | string | The role to check for. |
Returns
Type:bool
true if the user has the specified role; otherwise, false.
HasScope Extension
Extension method from
System.Security.Claims.McpAuthentication_ClaimsPrincipalExtensionsSyntax
Parameters
| Name | Type | Description |
|---|---|---|
principal | System.Security.Claims.ClaimsPrincipal | The claims principal to check. |
scope | string | The scope to check for. |
Returns
Type:bool
true if the user has the specified scope; otherwise, false.