| | | 1 | | // ----------------------------------------------------------------------- |
| | | 2 | | // <copyright file="WindowsUserPrincipal.cs" company="Stéphane ANDRE"> |
| | | 3 | | // Copyright (c) Stéphane ANDRE. All rights reserved. |
| | | 4 | | // </copyright> |
| | | 5 | | // ----------------------------------------------------------------------- |
| | | 6 | | |
| | | 7 | | using System; |
| | | 8 | | using System.Security.Principal; |
| | | 9 | | using MyNet.Utilities; |
| | | 10 | | |
| | | 11 | | namespace MyNet.Platform.Windows.Authentication; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Represents a Windows user principal with convenient name and domain properties. |
| | | 15 | | /// </summary> |
| | | 16 | | /// <remarks> |
| | | 17 | | /// Initializes a new instance of the <see cref="WindowsUserPrincipal"/> class. |
| | | 18 | | /// </remarks> |
| | | 19 | | /// <param name="identity">The identity associated with the principal.</param> |
| | | 20 | | /// <param name="roles">The roles for the principal.</param> |
| | | 21 | | public class WindowsUserPrincipal(IIdentity identity, string[] roles) |
| | 15 | 22 | | : GenericPrincipal(identity ?? throw new ArgumentNullException(nameof(identity)), roles ?? throw new ArgumentNullExc |
| | | 23 | | { |
| | | 24 | | /// <summary> |
| | | 25 | | /// Gets the user name extracted from the identity. |
| | | 26 | | /// </summary> |
| | 15 | 27 | | public string Name { get; } = identity.GetName(); |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Gets the domain extracted from the identity. |
| | | 31 | | /// </summary> |
| | 15 | 32 | | public string Domain { get; } = identity.GetDomain(); |
| | | 33 | | } |
| | | 34 | | |