diff --git a/src/CommonLib/Processors/GPOLocalGroupProcessor.cs b/src/CommonLib/Processors/GPOLocalGroupProcessor.cs index 2ed90e7d..c579e0fb 100644 --- a/src/CommonLib/Processors/GPOLocalGroupProcessor.cs +++ b/src/CommonLib/Processors/GPOLocalGroupProcessor.cs @@ -63,7 +63,18 @@ public async Task ReadGPOLocalGroups(string gpLink, string if (gpLink == null) return ret; - var domain = Helpers.DistinguishedNameToDomain(distinguishedName); + string domain; + //If our dn is null, use our default domain + if (string.IsNullOrEmpty(distinguishedName)) { + if (!_utils.GetDomain(out var d)) { + return ret; + } + + domain = d.Name; + } else { + domain = Helpers.DistinguishedNameToDomain(distinguishedName); + } + // First lets check if this OU actually has computers that it contains. If not, then we'll ignore it. // Its cheaper to fetch the affected computers from LDAP first and then process the GPLinks var affectedComputers = new List(); diff --git a/test/unit/GPOLocalGroupProcessorTest.cs b/test/unit/GPOLocalGroupProcessorTest.cs index 84643074..4e7ad967 100644 --- a/test/unit/GPOLocalGroupProcessorTest.cs +++ b/test/unit/GPOLocalGroupProcessorTest.cs @@ -150,10 +150,7 @@ public async Task GPOLocalGroupProcessor_ReadGPOLocalGroups_Null_Gpcfilesyspath( var result = await processor.ReadGPOLocalGroups(testGPLinkProperty, null); Assert.NotNull(result); - Assert.Single(result.AffectedComputers); - var actual = result.AffectedComputers.First(); - Assert.Equal(Label.Computer, actual.ObjectType); - Assert.Equal("teapot", actual.ObjectIdentifier); + Assert.Empty(result.AffectedComputers); } [Fact] @@ -189,12 +186,12 @@ public async Task GPOLocalGroupProcessor_ReadGPOLocalGroups() { "[LDAP:/o=foo/ou=foo Group (ABC123)/cn=foouser (blah)123/dc=somedomain;0;][LDAP:/o=foo/ou=foo Group (ABC123)/cn=foouser (blah)123/dc=someotherdomain;2;]"; var result = await processor.ReadGPOLocalGroups(testGPLinkProperty, null); + var domain = MockableDomain.Construct("TESTLAB.LOCAL"); + mockLDAPUtils.Setup(x => x.GetDomain(out domain)).Returns(true); + mockLDAPUtils.VerifyAll(); Assert.NotNull(result); - Assert.Single(result.AffectedComputers); - var actual = result.AffectedComputers.First(); - Assert.Equal(Label.Computer, actual.ObjectType); - Assert.Equal("teapot", actual.ObjectIdentifier); + Assert.Empty(result.AffectedComputers); } [Fact]