forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalPrincipal.cs
More file actions
97 lines (85 loc) · 2.73 KB
/
Copy pathLocalPrincipal.cs
File metadata and controls
97 lines (85 loc) · 2.73 KB
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
using System.Security.Principal;
namespace Microsoft.PowerShell.Commands
{
/// <summary>
/// Defines the source of a Principal
/// </summary>
public enum PrincipalSource
{
/// <summary>
/// The principal source is unknown or could not be determined
/// </summary>
Unknown = 0,
/// <summary>
/// The principal is sourced from the local Windows Security Accounts Manager.
/// </summary>
Local,
/// <summary>
/// The principal is sourced from an Active Directory domain.
/// </summary>
ActiveDirectory,
/// <summary>
/// The principal is sourced from Azure Active Directory.
/// </summary>
AzureAD,
/// <summary>
/// The principal is a Microsoft Account, such as
/// <b>MicrosoftAccount\user@domain.com</b>
/// </summary>
MicrosoftAccount
}
/// <summary>
/// Represents a Principal. Serves as a base class for Users and Groups.
/// </summary>
public class LocalPrincipal
{
#region Public Properties
/// <summary>
/// The account name of the Principal.
/// </summary>
public string Name { get; set; }
/// <summary>
/// The Security Identifier that uniquely identifies the Principal/
/// </summary>
public SecurityIdentifier SID { get; set; }
/// <summary>
/// Indicates the account store from which the principal is sourced.
/// One of the PrincipalSource enumerations.
/// </summary>
public PrincipalSource? PrincipalSource { get; set; }
/// <summary>
/// The object class that represents this principal.
/// This can be User or Group.
/// </summary>
public string ObjectClass { get; set; }
#endregion Public Properties
#region Construction
/// <summary>
/// Initializes a new LocalPrincipal object.
/// </summary>
public LocalPrincipal()
{
}
/// <summary>
/// Initializes a new LocalPrincipal object with the specified name.
/// </summary>
/// <param name="name">Name of the new LocalPrincipal.</param>
public LocalPrincipal(string name)
{
Name = name;
}
#endregion Construction
#region Public Methods
/// <summary>
/// Provides a string representation of the Principal.
/// </summary>
/// <returns>
/// A string, in SDDL form, representing the Principal.
/// </returns>
public override string ToString()
{
return Name ?? SID.ToString();
}
#endregion Public Methods
}
}