From feb4ae6d2aa99a0e20ec8619e7f9895949def082 Mon Sep 17 00:00:00 2001 From: Ulises Rangel Date: Thu, 16 Nov 2023 15:37:59 -0600 Subject: [PATCH 1/3] chore: add CertServices to collection methods --- src/CommonLib/Enums/CollectionMethods.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CommonLib/Enums/CollectionMethods.cs b/src/CommonLib/Enums/CollectionMethods.cs index 1964f863..f24f3eea 100644 --- a/src/CommonLib/Enums/CollectionMethods.cs +++ b/src/CommonLib/Enums/CollectionMethods.cs @@ -24,6 +24,7 @@ public enum ResolvedCollectionMethod UserRights = 1 << 15, CARegistry = 1 << 16, DCRegistry = 1 << 17, + CertServices = 1 << 18, LocalGroups = DCOM | RDP | LocalAdmin | PSRemote, ComputerOnly = LocalGroups | Session | UserRights | CARegistry | DCRegistry, DCOnly = ACL | Container | Group | ObjectProps | Trusts | GPOLocalGroup, From 2cde9e5d201ecb4326b7ad442da6ccc6e01df287 Mon Sep 17 00:00:00 2001 From: Ulises Rangel Date: Fri, 17 Nov 2023 08:39:37 -0600 Subject: [PATCH 2/3] chore: add certservices method to dconly and default options --- src/CommonLib/Enums/CollectionMethods.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CommonLib/Enums/CollectionMethods.cs b/src/CommonLib/Enums/CollectionMethods.cs index f24f3eea..d4ebf61e 100644 --- a/src/CommonLib/Enums/CollectionMethods.cs +++ b/src/CommonLib/Enums/CollectionMethods.cs @@ -27,8 +27,8 @@ public enum ResolvedCollectionMethod CertServices = 1 << 18, LocalGroups = DCOM | RDP | LocalAdmin | PSRemote, ComputerOnly = LocalGroups | Session | UserRights | CARegistry | DCRegistry, - DCOnly = ACL | Container | Group | ObjectProps | Trusts | GPOLocalGroup, - Default = Group | Session | Trusts | ACL | ObjectProps | LocalGroups | SPNTargets | Container, + DCOnly = ACL | Container | Group | ObjectProps | Trusts | GPOLocalGroup | CertServices, + Default = Group | Session | Trusts | ACL | ObjectProps | LocalGroups | SPNTargets | Container | CertServices, All = Default | LoggedOn | GPOLocalGroup | UserRights | CARegistry | DCRegistry } } \ No newline at end of file From 37438c11e898ad623d016f183e93603959836559 Mon Sep 17 00:00:00 2001 From: Ulises Rangel Date: Fri, 17 Nov 2023 10:10:08 -0600 Subject: [PATCH 3/3] feat: handle deduplication in getFilter method for LDAPFilter --- src/CommonLib/LDAPQueries/LDAPFilter.cs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/CommonLib/LDAPQueries/LDAPFilter.cs b/src/CommonLib/LDAPQueries/LDAPFilter.cs index 5474e9b4..ab7296ad 100644 --- a/src/CommonLib/LDAPQueries/LDAPFilter.cs +++ b/src/CommonLib/LDAPQueries/LDAPFilter.cs @@ -245,16 +245,23 @@ public LDAPFilter AddFilter(string filter, bool enforce) /// public string GetFilter() { - var temp = string.Join("", _filterParts.ToArray()); - if (_filterParts.Count == 1) - temp = _filterParts[0]; - else if (_filterParts.Count > 1) - temp = $"(|{temp})"; - var mandatory = string.Join("", _mandatory.ToArray()); - temp = _mandatory.Count > 0 ? $"(&{temp}{mandatory})" : temp; + var filterPartList = _filterParts.ToArray().Distinct(); + var mandatoryList = _mandatory.ToArray().Distinct(); - return temp; + var filterPartsExceptMandatory = filterPartList.Except(mandatoryList).ToList(); + + var filterPartsDistinct = string.Join("", filterPartsExceptMandatory); + var mandatoryDistinct = string.Join("", mandatoryList); + + if (filterPartsExceptMandatory.Count == 1) + filterPartsDistinct = filterPartsExceptMandatory[0]; + else if (filterPartsExceptMandatory.Count > 1) + filterPartsDistinct = $"(|{filterPartsDistinct})"; + + filterPartsDistinct = _mandatory.Count > 0 ? $"(&{filterPartsDistinct}{mandatoryDistinct})" : filterPartsDistinct; + + return filterPartsDistinct; } public IEnumerable GetFilterList()