Skip to content

Commit 6d95d6a

Browse files
authored
BED-6619 collection of objectguid (#253)
* Adding object guid to collection * Fixing up unit tests * Ensuring that GUID as all uppercase * Adding more robust unit tests to appease code rabbit * Removing unncessary property adds
1 parent 1ec7cba commit 6d95d6a

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

src/CommonLib/LdapQueries/CommonProperties.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static class CommonProperties
3131
{
3232
LDAPProperties.SAMAccountName, LDAPProperties.DistinguishedName, LDAPProperties.DNSHostName,
3333
LDAPProperties.SAMAccountType, LDAPProperties.OperatingSystem, LDAPProperties.PasswordLastSet,
34-
LDAPProperties.LastLogonTimestamp
34+
LDAPProperties.LastLogonTimestamp, LDAPProperties.ObjectGUID
3535
};
3636

3737
public static readonly string[] ACLProps =

src/CommonLib/Processors/LdapPropertyProcessor.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,20 @@ await SendComputerStatus(new CSVComputerStatus {
436436
}
437437
}
438438

439+
var objectGuidBytes = entry.GetByteProperty(LDAPProperties.ObjectGUID);
440+
if (objectGuidBytes != null && objectGuidBytes.Length == 16)
441+
{
442+
try
443+
{
444+
Guid guid = new Guid(objectGuidBytes);
445+
props.Add(LDAPProperties.ObjectGUID, guid.ToString().ToUpper());
446+
}
447+
catch
448+
{
449+
// Skip malformed GUID bytes
450+
}
451+
}
452+
439453
compProps.DumpSMSAPassword = smsaPrincipals.ToArray();
440454

441455
compProps.Props = props;

test/unit/LdapPropertyTests.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ public async Task LDAPPropertyProcessor_ReadComputerProperties_HappyPath()
446446
{"lastlogon", "132673011142753043"},
447447
{"lastlogontimestamp", "132670318095676525"},
448448
{"operatingsystem", "Windows 10 Enterprise"},
449+
{"objectguid", Guid.Parse("a6f75ba4-f1ae-4b47-a606-e3a0a69aec83").ToByteArray()},
449450
{"operatingsystemservicepack", "1607"},
450451
{"mail", "test@testdomain.com"},
451452
{"admincount", "c"},
@@ -542,6 +543,9 @@ public async Task LDAPPropertyProcessor_ReadComputerProperties_HappyPath()
542543
{
543544
Assert.Equal("Success", status.Status);
544545
}
546+
Assert.Contains("objectguid", keys);
547+
Assert.Equal("A6F75BA4-F1AE-4B47-A606-E3A0A69AEC83", props["objectguid"]);
548+
545549
}
546550

547551
[Fact]
@@ -597,6 +601,7 @@ public async Task LDAPPropertyProcessor_ReadComputerProperties_TestBadPaths()
597601
Assert.False((bool)props["trustedtoauth"]);
598602
Assert.Contains("sidhistory", keys);
599603
Assert.Empty(props["sidhistory"] as string[]);
604+
Assert.DoesNotContain("objectguid", keys);
600605
}
601606

602607

@@ -668,7 +673,6 @@ public async Task LDAPPropertyProcessor_ReadComputerProperties_TestDumpSMSAPassw
668673
var testDumpSMSAPassword = test.DumpSMSAPassword;
669674
Assert.Equal(2, testDumpSMSAPassword.Length);
670675
Assert.Equal(expected, testDumpSMSAPassword);
671-
672676
}
673677

674678
[Fact]
@@ -1380,6 +1384,7 @@ public async Task LDAPPropertyProcessor_ReadComputerProperties_TestDelegatesNull
13801384
{"operatingsystem", "Windows 10 Enterprise"},
13811385
{"operatingsystemservicepack", "1607"},
13821386
{"mail", "test@testdomain.com"},
1387+
{"objectguid", Guid.Parse("a6f75ba4-f1ae-4b47-a606-e3a0a69aec83").ToByteArray()},
13831388
{"admincount", "c"},
13841389
{
13851390
"sidhistory", new[]
@@ -1425,6 +1430,9 @@ public async Task LDAPPropertyProcessor_ReadComputerProperties_TestDelegatesNull
14251430
ObjectIdentifier = "S-1-5-21-3130019616-2776909439-2417379446-1001",
14261431
ObjectType = Label.Computer
14271432
}, test.AllowedToDelegate);
1433+
1434+
Assert.Contains("objectguid", keys);
1435+
Assert.Equal("A6F75BA4-F1AE-4B47-A606-E3A0A69AEC83", props["objectguid"]);
14281436
}
14291437

14301438
[WindowsOnlyFact]
@@ -1445,13 +1453,14 @@ public async Task LDAPPropertyProcessor_ReadComputerProperties_AllowedToActOnBeh
14451453
{"lastlogontimestamp", "132670318095676525"},
14461454
{"operatingsystem", "Windows 10 Enterprise"},
14471455
{"operatingsystemservicepack", "1607"},
1456+
{"objectguid", Guid.Parse("a6f75ba4-f1ae-4b47-a606-e3a0a69aec83").ToByteArray()},
14481457
{"mail", "test@testdomain.com"},
14491458
{"admincount", "c"},
14501459
{
1451-
"msds-allowedtoactonbehalfofotheridentity",
1452-
1460+
"msds-allowedtoactonbehalfofotheridentity",
1461+
14531462
Utils.B64ToBytes("AQUAAAAAAAUVAAAAIE+Qun9GhKV2SBaQUQQAAA==")
1454-
1463+
14551464
}
14561465
}, "S-1-5-21-3130019616-2776909439-2417379446-1101","");
14571466

0 commit comments

Comments
 (0)