1use windows_sddl::sid::Guid;
9
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum GuidClass {
13 ExtendedRight,
15 Attribute,
17 ValidatedWrite,
19}
20
21pub struct KnownGuid {
23 pub name: &'static str,
24 pub class: GuidClass,
25 guid: &'static str,
26}
27
28impl KnownGuid {
29 const fn new(name: &'static str, class: GuidClass, guid: &'static str) -> Self {
30 KnownGuid { name, class, guid }
31 }
32 pub fn guid(&self) -> Guid {
33 Guid::parse(self.guid).expect("static catalog GUID is valid")
34 }
35 pub fn matches(&self, g: &Guid) -> bool {
36 self.guid() == *g
37 }
38}
39
40use GuidClass::{Attribute, ExtendedRight, ValidatedWrite};
41
42pub const REPL_GET_CHANGES: KnownGuid = KnownGuid::new(
46 "DS-Replication-Get-Changes",
47 ExtendedRight,
48 "1131f6aa-9c07-11d1-f79f-00c04fc2dcd2",
49);
50pub const REPL_GET_CHANGES_ALL: KnownGuid = KnownGuid::new(
52 "DS-Replication-Get-Changes-All",
53 ExtendedRight,
54 "1131f6ad-9c07-11d1-f79f-00c04fc2dcd2",
55);
56pub const REPL_GET_CHANGES_FILTERED: KnownGuid = KnownGuid::new(
58 "DS-Replication-Get-Changes-In-Filtered-Set",
59 ExtendedRight,
60 "89e95b76-444d-4c62-991a-0facbeda640c",
61);
62pub const FORCE_CHANGE_PASSWORD: KnownGuid = KnownGuid::new(
64 "User-Force-Change-Password",
65 ExtendedRight,
66 "00299570-246d-11d0-a768-00aa006e0529",
67);
68pub const REANIMATE_TOMBSTONES: KnownGuid = KnownGuid::new(
70 "Reanimate-Tombstones",
71 ExtendedRight,
72 "45ec5156-db7e-47bb-b53f-dbeb2d03c40f",
73);
74pub const ENROLLMENT: KnownGuid = KnownGuid::new(
76 "Certificate-Enrollment",
77 ExtendedRight,
78 "0e10c968-78fb-11d2-90d4-00c04f79dc55",
79);
80pub const AUTO_ENROLLMENT: KnownGuid = KnownGuid::new(
82 "Certificate-AutoEnrollment",
83 ExtendedRight,
84 "a05b8cc2-17bc-4802-a710-e7c15ab866a2",
85);
86
87pub const MEMBER: KnownGuid =
91 KnownGuid::new("member", Attribute, "bf9679c0-0de6-11d0-a285-00aa003049e2");
92pub const KEY_CREDENTIAL_LINK: KnownGuid = KnownGuid::new(
94 "msDS-KeyCredentialLink",
95 Attribute,
96 "5b47d60f-6090-40b2-9f37-2a4de88f3063",
97);
98pub const RBCD: KnownGuid = KnownGuid::new(
100 "msDS-AllowedToActOnBehalfOfOtherIdentity",
101 Attribute,
102 "3f78c3e5-f79a-46bd-a0b8-9d18116ddc79",
103);
104pub const SPN: KnownGuid = KnownGuid::new(
106 "servicePrincipalName",
107 Attribute,
108 "f3a64788-5306-11d1-a9c5-0000f80367c1",
109);
110pub const ALT_SECURITY_IDENTITIES: KnownGuid = KnownGuid::new(
112 "altSecurityIdentities",
113 Attribute,
114 "00fbf30c-91fe-11d1-aebc-0000f80367c1",
115);
116pub const ALLOWED_TO_DELEGATE_TO: KnownGuid = KnownGuid::new(
118 "msDS-AllowedToDelegateTo",
119 Attribute,
120 "800d94d7-b7a1-42a1-b14d-7cae1423d07f",
121);
122pub const GP_LINK: KnownGuid =
124 KnownGuid::new("gPLink", Attribute, "f30e3bbe-9ff0-11d1-b603-0000f80367c1");
125
126pub const SELF_MEMBERSHIP: KnownGuid = KnownGuid::new(
130 "Self-Membership",
131 ValidatedWrite,
132 "bf9679c0-0de6-11d0-a285-00aa003049e2",
133);
134pub const VALIDATED_SPN: KnownGuid = KnownGuid::new(
136 "Validated-SPN",
137 ValidatedWrite,
138 "f3a64788-5306-11d1-a9c5-0000f80367c1",
139);
140
141pub const ALL: &[&KnownGuid] = &[
143 &REPL_GET_CHANGES,
144 &REPL_GET_CHANGES_ALL,
145 &REPL_GET_CHANGES_FILTERED,
146 &FORCE_CHANGE_PASSWORD,
147 &REANIMATE_TOMBSTONES,
148 &ENROLLMENT,
149 &AUTO_ENROLLMENT,
150 &MEMBER,
151 &KEY_CREDENTIAL_LINK,
152 &RBCD,
153 &SPN,
154 &ALT_SECURITY_IDENTITIES,
155 &ALLOWED_TO_DELEGATE_TO,
156 &GP_LINK,
157];
158
159pub fn name_of(g: &Guid, class: GuidClass) -> Option<&'static str> {
164 if class == ValidatedWrite {
165 for k in [&SELF_MEMBERSHIP, &VALIDATED_SPN] {
166 if k.matches(g) {
167 return Some(k.name);
168 }
169 }
170 }
171 ALL.iter()
172 .find(|k| k.class == class && k.matches(g))
173 .map(|k| k.name)
174}
175
176pub fn is_replication_right(g: &Guid) -> bool {
178 REPL_GET_CHANGES.matches(g)
179 || REPL_GET_CHANGES_ALL.matches(g)
180 || REPL_GET_CHANGES_FILTERED.matches(g)
181}
182
183pub fn is_enrollment_right(g: &Guid) -> bool {
185 ENROLLMENT.matches(g) || AUTO_ENROLLMENT.matches(g)
186}