Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BED-4965 - Owns/Owner Rework #124

Open
wants to merge 4 commits into
base: 2.X
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions src/Runtime/ObjectProcessors.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Configuration;
using System.Runtime.Remoting;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Channels;
Expand Down Expand Up @@ -130,8 +132,9 @@ private async Task<User> ProcessUserObject(IDirectoryObject entry,
ret.DomainSID = resolvedSearchResult.DomainSid;

if ((_methods & CollectionMethod.ACL) != 0) {
var aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry)
.ToArrayAsync(cancellationToken: _cancellationToken);
(var aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
var gmsa = entry.GetByteProperty(LDAPProperties.GroupMSAMembership);
ret.Aces = aces.Concat(await _aclProcessor.ProcessGMSAReaders(gmsa, resolvedSearchResult.Domain)
.ToArrayAsync(cancellationToken: _cancellationToken)).ToArray();
Expand Down Expand Up @@ -187,7 +190,9 @@ private async Task<Computer> ProcessComputerObject(IDirectoryObject entry,
ret.DomainSID = resolvedSearchResult.DomainSid;

if ((_methods & CollectionMethod.ACL) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync(_cancellationToken);
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand Down Expand Up @@ -320,7 +325,9 @@ private async Task<Group> ProcessGroupObject(IDirectoryObject entry,
ret.Properties.Add("samaccountname", entry.GetProperty(LDAPProperties.SAMAccountName));

if ((_methods & CollectionMethod.ACL) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync(cancellationToken: _cancellationToken);
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand Down Expand Up @@ -362,7 +369,9 @@ private async Task<Domain> ProcessDomainObject(IDirectoryObject entry,
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
ret.InheritanceHashes = _aclProcessor.GetInheritedAceHashes(entry, resolvedSearchResult).ToArray();
Expand Down Expand Up @@ -400,7 +409,9 @@ private async Task<GPO> ProcessGPOObject(IDirectoryObject entry,
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand All @@ -425,7 +436,9 @@ private async Task<OU> ProcessOUObject(IDirectoryObject entry,
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
ret.InheritanceHashes = _aclProcessor.GetInheritedAceHashes(entry, resolvedSearchResult).ToArray();
Expand Down Expand Up @@ -471,8 +484,9 @@ private async Task<Container> ProcessContainerObject(IDirectoryObject entry,
}

if ((_methods & CollectionMethod.ACL) != 0 || (_methods & CollectionMethod.CertServices) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry)
.ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
ret.InheritanceHashes = _aclProcessor.GetInheritedAceHashes(entry, resolvedSearchResult).ToArray();
Expand Down Expand Up @@ -501,7 +515,9 @@ private async Task<RootCA> ProcessRootCA(IDirectoryObject entry, ResolvedSearchR


if ((_methods & CollectionMethod.ACL) != 0 || (_methods & CollectionMethod.CertServices) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand All @@ -528,7 +544,9 @@ private async Task<AIACA> ProcessAIACA(IDirectoryObject entry, ResolvedSearchRes
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0 || (_methods & CollectionMethod.CertServices) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand Down Expand Up @@ -556,7 +574,9 @@ private async Task<EnterpriseCA> ProcessEnterpriseCA(IDirectoryObject entry,
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0 || (_methods & CollectionMethod.CertServices) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand Down Expand Up @@ -634,7 +654,9 @@ private async Task<NTAuthStore> ProcessNTAuthStore(IDirectoryObject entry,
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0 || (_methods & CollectionMethod.CertServices) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand Down Expand Up @@ -669,7 +691,9 @@ private async Task<CertTemplate> ProcessCertTemplate(IDirectoryObject entry,
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0 || (_methods & CollectionMethod.CertServices) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand Down Expand Up @@ -697,7 +721,9 @@ private async Task<IssuancePolicy> ProcessIssuancePolicy(IDirectoryObject entry,
ret.Properties = new Dictionary<string, object>(GetCommonProperties(entry, resolvedSearchResult));

if ((_methods & CollectionMethod.ACL) != 0 || (_methods & CollectionMethod.CertServices) != 0) {
ret.Aces = await _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArrayAsync();
(ret.Aces, bool doesAnyAceGrantOwnerRights, bool doesAnyInheritedAceGrantOwnerRights) = await _aclProcessor.ProcessACL(resolvedSearchResult, entry, true);
ret.Properties.Add("doesanyacegrantownerrights", doesAnyAceGrantOwnerRights);
ret.Properties.Add("doesanyinheritedacegrantownerrights", doesAnyInheritedAceGrantOwnerRights);
ret.IsACLProtected = _aclProcessor.IsACLProtected(entry);
ret.Properties.Add("isaclprotected", ret.IsACLProtected);
}
Expand Down
Loading