| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="IdentityExtensions.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System.Security.Principal; |
| | | 8 | | using MyNet.Utilities.Authentication; |
| | | 9 | | |
| | | 10 | | #pragma warning disable IDE0130 // Namespace does not match folder structure |
| | | 11 | | namespace MyNet.Utilities; |
| | | 12 | | #pragma warning restore IDE0130 // Namespace does not match folder structure |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Provides convenience extension methods for reading name components from an <see cref="IIdentity"/>. |
| | | 16 | | /// </summary> |
| | | 17 | | public static class IdentityExtensions |
| | | 18 | | { |
| | | 19 | | extension(IIdentity identity) |
| | | 20 | | { |
| | | 21 | | /// <summary> |
| | | 22 | | /// Extracts the domain part from the identity name. |
| | | 23 | | /// Returns an empty string when the identity does not contain a domain. |
| | | 24 | | /// </summary> |
| | 19 | 25 | | public string GetDomain() => IdentityHelper.GetDomain(identity.Name); |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Extracts the user name part from the identity name. |
| | | 29 | | /// </summary> |
| | 19 | 30 | | public string GetName() => IdentityHelper.GetName(identity.Name); |
| | | 31 | | } |
| | | 32 | | } |
| | | 33 | | |