diff --git a/src/CommonLib/Processors/LdapPropertyProcessor.cs b/src/CommonLib/Processors/LdapPropertyProcessor.cs index 5e1d7ed8..1fed2768 100644 --- a/src/CommonLib/Processors/LdapPropertyProcessor.cs +++ b/src/CommonLib/Processors/LdapPropertyProcessor.cs @@ -53,6 +53,21 @@ private static Dictionary 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; } @@ -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; diff --git a/test/unit/CommonLibHelperTests.cs b/test/unit/CommonLibHelperTests.cs index 0cad80e1..f2e4c0c1 100644 --- a/test/unit/CommonLibHelperTests.cs +++ b/test/unit/CommonLibHelperTests.cs @@ -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) { @@ -322,7 +322,7 @@ static string BuildExpectedHexSid(string sid) } } - [Fact] + [WindowsOnlyFact] public void ConvertSidToHexSid_InvalidSid_Throws() { Assert.ThrowsAny(() => Helpers.ConvertSidToHexSid("NOT-A-SID"));