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

chore: add CertServices to collection methods #83

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions src/CommonLib/Enums/CollectionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ 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,
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
}
}
23 changes: 15 additions & 8 deletions src/CommonLib/LDAPQueries/LDAPFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,23 @@ public LDAPFilter AddFilter(string filter, bool enforce)
/// <returns></returns>
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<string> GetFilterList()
Expand Down
Loading