Skip to content

Commit

Permalink
chore: use helper func for LookupSidType
Browse files Browse the repository at this point in the history
  • Loading branch information
rvazarkar committed Oct 4, 2022
1 parent 10d4c20 commit 9086c65
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/CommonLib/LDAPUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,12 @@ public Label LookupSidType(string sid, string domain)
{
if (Cache.GetIDType(sid, out var type))
return type;

var hex = Helpers.ConvertSidToHexSid(sid);
if (hex == null)
return Label.Base;


var rDomain = GetDomainNameFromSid(sid) ?? domain;
_log.LogInformation("looking up sid {sid} in domain {domain}", sid, domain);

var result =
QueryLDAP($"(objectsid={hex})", SearchScope.Subtree, CommonProperties.TypeResolutionProps, rDomain)
QueryLDAP(CommonFilters.SpecificSID(sid), SearchScope.Subtree, CommonProperties.TypeResolutionProps, rDomain)
.DefaultIfEmpty(null).FirstOrDefault();

type = result?.GetLabel() ?? Label.Base;
Expand Down

0 comments on commit 9086c65

Please sign in to comment.