// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Security.Principal; namespace Microsoft.PowerShell.Commands { /// /// Defines the source of a Principal. /// public enum PrincipalSource { /// /// The principal source is unknown or could not be determined. /// Unknown = 0, /// /// The principal is sourced from the local Windows Security Accounts Manager. /// Local, /// /// The principal is sourced from an Active Directory domain. /// ActiveDirectory, /// /// The principal is sourced from Azure Active Directory. /// AzureAD, /// /// The principal is a Microsoft Account, such as /// MicrosoftAccount\user@domain.com /// MicrosoftAccount } /// /// Represents a Principal. Serves as a base class for Users and Groups. /// public class LocalPrincipal { #region Public Properties /// /// The account name of the Principal. /// public string Name { get; set; } /// /// The Security Identifier that uniquely identifies the Principal/ /// public SecurityIdentifier SID { get; set; } /// /// Indicates the account store from which the principal is sourced. /// One of the PrincipalSource enumerations. /// public PrincipalSource? PrincipalSource { get; set; } /// /// The object class that represents this principal. /// This can be User or Group. /// public string ObjectClass { get; set; } #endregion Public Properties #region Construction /// /// Initializes a new LocalPrincipal object. /// public LocalPrincipal() { } /// /// Initializes a new LocalPrincipal object with the specified name. /// /// Name of the new LocalPrincipal. public LocalPrincipal(string name) { Name = name; } #endregion Construction #region Public Methods /// /// Provides a string representation of the Principal. /// /// /// A string, in SDDL form, representing the Principal. /// public override string ToString() { return Name ?? SID.ToString(); } #endregion Public Methods } }