Skip to content
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
29 changes: 15 additions & 14 deletions src/CommonLib/Processors/LdapPropertyProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ private static Dictionary<string, object> GetCommonProps(IDirectoryObject entry)
ret["whencreated"] = Helpers.ConvertTimestampToUnixEpoch(wc);
}

if (entry.TryGetByteProperty(LDAPProperties.ObjectGUID, out var objectguid)) {
if (objectguid != null && objectguid.Length == 16)
{
try
{
Guid guid = new Guid(objectguid);
ret["objectguid"] = guid.ToString().ToUpperInvariant();
}
catch
{
// Skip malformed GUID bytes
}
}
}

return ret;
}

Expand Down Expand Up @@ -441,20 +456,6 @@ await SendComputerStatus(new CSVComputerStatus {
}
}

var objectGuidBytes = entry.GetByteProperty(LDAPProperties.ObjectGUID);
if (objectGuidBytes != null && objectGuidBytes.Length == 16)
{
try
{
Guid guid = new Guid(objectGuidBytes);
props.Add(LDAPProperties.ObjectGUID, guid.ToString().ToUpper());
}
catch
{
// Skip malformed GUID bytes
}
}

compProps.DumpSMSAPassword = smsaPrincipals.ToArray();

compProps.Props = props;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/CommonLibHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public void DomainNameToDistinguishedName_DotsBecomeDcComponents()
Assert.Equal("DC=test,DC=local", result);
}

[Theory]
[WindowsOnlyTheory]
[InlineData("S-1-5-32-544", "\\01\\02\\00\\00\\00\\00\\00\\05\\20\\00\\00\\00\\20\\02\\00\\00")]
public void ConvertSidToHexSid_ValidSid_MatchesSecurityIdentifierBinaryForm(string sid, string expectedHexSid)
{
Expand All @@ -322,7 +322,7 @@ static string BuildExpectedHexSid(string sid)
}
}

[Fact]
[WindowsOnlyFact]
public void ConvertSidToHexSid_InvalidSid_Throws()
{
Assert.ThrowsAny<ArgumentException>(() => Helpers.ConvertSidToHexSid("NOT-A-SID"));
Expand Down
Loading