// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System; using Microsoft.PowerShell.LocalAccounts; namespace Microsoft.PowerShell.Commands { /// /// Describes a Local User. /// Objects of this type are provided to and returned from user-related Cmdlets. /// public class LocalUser : LocalPrincipal { #region Public Properties /// /// The date and time at which this user account expires. /// A value of null indicates that the account never expires. /// public DateTime? AccountExpires { get; set; } /// /// A short description of the User. /// public string Description { get; set; } /// /// Indicates whether the user account is enabled (true) or disabled (false). /// public bool Enabled { get; set; } /// /// The user's full name. Not the same as the User name. /// public string FullName { get; set; } /// /// The date and time at which this user account password is allowed /// to be changed. The password cannot be changed before this time. /// A value of null indicates that the password can be changed anytime. /// public DateTime? PasswordChangeableDate { get; set; } /// /// The date and time at which this user account password must be changed /// to a new password. A value of null indicates that the password will /// never expire. /// public DateTime? PasswordExpires { get; set; } /// /// Indicates whether the user is allowed to change the password (true) /// or not (false). /// public bool UserMayChangePassword { get; set; } /// /// Indicates whether the user must have a password (true) or not (false). /// public bool PasswordRequired { get; set; } /// /// The date and time at which this user last changed the account password. /// public DateTime? PasswordLastSet { get; set; } /// /// The date and time at which the user last logged on to the machine. /// public DateTime? LastLogon { get; set; } #endregion Public Properties #region Construction /// /// Initializes a new LocalUser object. /// public LocalUser() { ObjectClass = Strings.ObjectClassUser; } /// /// Initializes a new LocalUser object with the specified name. /// /// Name of the new LocalUser. public LocalUser(string name) : base(name) { ObjectClass = Strings.ObjectClassUser; } /// /// Construct a new LocalUser object that is a copy of another. /// /// The LocalUser object to copy. private LocalUser(LocalUser other) : this(other.Name) { SID = other.SID; PrincipalSource = other.PrincipalSource; ObjectClass = other.ObjectClass; AccountExpires = other.AccountExpires; Description = other.Description; Enabled = other.Enabled; FullName = other.FullName; PasswordChangeableDate = other.PasswordChangeableDate; PasswordExpires = other.PasswordExpires; UserMayChangePassword = other.UserMayChangePassword; PasswordRequired = other.PasswordRequired; PasswordLastSet = other.PasswordLastSet; LastLogon = other.LastLogon; } #endregion Construction #region Public Methods /// /// Provides a string representation of the LocalUser object. /// /// /// A string containing the User Name. /// public override string ToString() { return Name ?? SID.ToString(); } /// /// Create a copy of a LocalUser object. /// /// /// A new LocalUser object with the same property values as this one. /// public LocalUser Clone() { return new LocalUser(this); } #endregion Public Methods } }