Skip to content

Commit f64cad4

Browse files
author
James Forshaw
committed
Added object and inherited columns.
1 parent c9e544a commit f64cad4

3 files changed

Lines changed: 103 additions & 41 deletions

File tree

NtApiDotNet/Acl.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using System;
1616
using System.Collections.Generic;
1717
using System.IO;
18+
using System.Linq;
1819
using System.Runtime.InteropServices;
1920

2021
namespace NtApiDotNet
@@ -91,7 +92,7 @@ public Acl(IEnumerable<Ace> aces) : this(aces, false)
9192
public Acl(string sddl)
9293
{
9394
SecurityDescriptor sd = new SecurityDescriptor(sddl);
94-
Acl acl = sd.Dacl ?? sd.Sacl
95+
Acl acl = sd.Dacl ?? sd.Sacl
9596
?? throw new ArgumentException("Must specify a DACL or a SACL", "sddl");
9697
Defaulted = acl.Defaulted;
9798
NullAcl = acl.NullAcl;
@@ -322,20 +323,12 @@ public Acl Canonicalize()
322323
/// <summary>
323324
/// Indicates the ACL has at least one conditional ACE.
324325
/// </summary>
325-
public bool HasConditionalAce
326-
{
327-
get
328-
{
329-
foreach (var ace in this)
330-
{
331-
if (ace.IsConditionalAce)
332-
{
333-
return true;
334-
}
335-
}
336-
return false;
337-
}
338-
}
326+
public bool HasConditionalAce => this.Any(ace => ace.IsConditionalAce);
327+
328+
/// <summary>
329+
/// Indicates the ACL has at least one object ACE.
330+
/// </summary>
331+
public bool HasObjectAce => this.Any(ace => ace.IsObjectAce);
339332
#endregion
340333

341334
#region Private Members

NtApiDotNet/Forms/AclViewerControl.Designer.cs

Lines changed: 50 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

NtApiDotNet/Forms/AclViewerControl.cs

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,45 @@ public void SetAcl(Acl acl, Type access_type, GenericMapping mapping, AccessMask
7575
_valid_access = valid_access;
7676
_is_container = is_container;
7777

78-
if (!acl.HasConditionalAce)
78+
bool has_conditional_ace = false;
79+
bool has_inherited_object_ace = false;
80+
bool has_object_ace = false;
81+
82+
foreach (var ace in acl)
83+
{
84+
if (ace.IsConditionalAce)
85+
{
86+
has_conditional_ace = true;
87+
}
88+
if (ace.IsObjectAce)
89+
{
90+
if (ace.ObjectType.HasValue)
91+
{
92+
has_object_ace = true;
93+
}
94+
if (ace.InheritedObjectType.HasValue)
95+
{
96+
has_inherited_object_ace = true;
97+
}
98+
}
99+
}
100+
101+
if (!has_conditional_ace)
79102
{
80103
listViewAcl.Columns.Remove(columnHeaderCondition);
81104
copyConditionToolStripMenuItem.Visible = false;
82105
}
83106

107+
if (!has_object_ace)
108+
{
109+
listViewAcl.Columns.Remove(columnHeaderObject);
110+
}
111+
112+
if (!has_inherited_object_ace)
113+
{
114+
listViewAcl.Columns.Remove(columnHeaderInheritedObject);
115+
}
116+
84117
foreach (var ace in acl)
85118
{
86119
var item = listViewAcl.Items.Add(ace.Type.ToString());
@@ -99,11 +132,21 @@ public void SetAcl(Acl acl, Type access_type, GenericMapping mapping, AccessMask
99132

100133
item.SubItems.Add(access);
101134
item.SubItems.Add(ace.Flags.ToString());
102-
if (ace.IsConditionalAce)
135+
if (has_conditional_ace)
103136
{
104137
item.SubItems.Add(ace.Condition);
105138
}
106139

140+
if (has_object_ace)
141+
{
142+
item.SubItems.Add(ace.ObjectType?.ToString() ?? string.Empty);
143+
}
144+
145+
if (has_inherited_object_ace)
146+
{
147+
item.SubItems.Add(ace.InheritedObjectType?.ToString() ?? string.Empty);
148+
}
149+
107150
item.Tag = ace;
108151

109152
switch (ace.Type)

0 commit comments

Comments
 (0)