File size: 4,715 Bytes
8c763fb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | // Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using Microsoft.PowerShell.LocalAccounts;
namespace Microsoft.PowerShell.Commands
{
/// <summary>
/// Describes a Local User.
/// Objects of this type are provided to and returned from user-related Cmdlets.
/// </summary>
public class LocalUser : LocalPrincipal
{
#region Public Properties
/// <summary>
/// The date and time at which this user account expires.
/// A value of null indicates that the account never expires.
/// </summary>
public DateTime? AccountExpires { get; set; }
/// <summary>
/// A short description of the User.
/// </summary>
public string Description { get; set; }
/// <summary>
/// Indicates whether the user account is enabled (true) or disabled (false).
/// </summary>
public bool Enabled { get; set; }
/// <summary>
/// The user's full name. Not the same as the User name.
/// </summary>
public string FullName { get; set; }
/// <summary>
/// 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.
/// </summary>
public DateTime? PasswordChangeableDate { get; set; }
/// <summary>
/// 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.
/// </summary>
public DateTime? PasswordExpires { get; set; }
/// <summary>
/// Indicates whether the user is allowed to change the password (true)
/// or not (false).
/// </summary>
public bool UserMayChangePassword { get; set; }
/// <summary>
/// Indicates whether the user must have a password (true) or not (false).
/// </summary>
public bool PasswordRequired { get; set; }
/// <summary>
/// The date and time at which this user last changed the account password.
/// </summary>
public DateTime? PasswordLastSet { get; set; }
/// <summary>
/// The date and time at which the user last logged on to the machine.
/// </summary>
public DateTime? LastLogon { get; set; }
#endregion Public Properties
#region Construction
/// <summary>
/// Initializes a new LocalUser object.
/// </summary>
public LocalUser()
{
ObjectClass = Strings.ObjectClassUser;
}
/// <summary>
/// Initializes a new LocalUser object with the specified name.
/// </summary>
/// <param name="name">Name of the new LocalUser.</param>
public LocalUser(string name)
: base(name)
{
ObjectClass = Strings.ObjectClassUser;
}
/// <summary>
/// Construct a new LocalUser object that is a copy of another.
/// </summary>
/// <param name="other">The LocalUser object to copy.</param>
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
/// <summary>
/// Provides a string representation of the LocalUser object.
/// </summary>
/// <returns>
/// A string containing the User Name.
/// </returns>
public override string ToString()
{
return Name ?? SID.ToString();
}
/// <summary>
/// Create a copy of a LocalUser object.
/// </summary>
/// <returns>
/// A new LocalUser object with the same property values as this one.
/// </returns>
public LocalUser Clone()
{
return new LocalUser(this);
}
#endregion Public Methods
}
}
|