private async Task <Domain> ProcessDomainObject(ISearchResultEntry entry, ResolvedSearchResult resolvedSearchResult) { var ret = new Domain { ObjectIdentifier = resolvedSearchResult.ObjectId }; ret.Properties.Add("domain", resolvedSearchResult.Domain); ret.Properties.Add("name", resolvedSearchResult.DisplayName); ret.Properties.Add("distinguishedname", entry.DistinguishedName.ToUpper()); ret.Properties.Add("domainsid", resolvedSearchResult.DomainSid); ret.Properties.Add("highvalue", true); if ((_methods & ResolvedCollectionMethod.ACL) != 0) { ret.Aces = _aclProcessor.ProcessACL(resolvedSearchResult, entry).ToArray(); ret.IsACLProtected = _aclProcessor.IsACLProtected(entry); } if ((_methods & ResolvedCollectionMethod.Trusts) != 0) { ret.Trusts = _domainTrustProcessor.EnumerateDomainTrusts(resolvedSearchResult.Domain).ToArray(); } if ((_methods & ResolvedCollectionMethod.ObjectProps) != 0) { ret.Properties = ContextUtils.Merge(ret.Properties, LDAPPropertyProcessor.ReadDomainProperties(entry)); if (_context.Flags.CollectAllProperties) { ret.Properties = ContextUtils.Merge(_ldapPropertyProcessor.ParseAllProperties(entry), ret.Properties); } } if ((_methods & ResolvedCollectionMethod.Container) != 0) { ret.ChildObjects = _containerProcessor.GetContainerChildObjects(resolvedSearchResult, entry).ToArray(); ret.Links = _containerProcessor.ReadContainerGPLinks(resolvedSearchResult, entry).ToArray(); } if ((_methods & ResolvedCollectionMethod.GPOLocalGroup) != 0) { var gplink = entry.GetProperty(LDAPProperties.GPLink); ret.GPOChanges = await _gpoLocalGroupProcessor.ReadGPOLocalGroups(gplink, entry.DistinguishedName); } return(ret); }
public void ContainerProcessor_GetContainerChildObjects_ReturnsCorrectData() { var mock = new Mock <MockLDAPUtils>(); var searchResults = new MockSearchResultEntry[] { //These first 4 should be filtered by our DN filters new( "CN=7868d4c8-ac41-4e05-b401-776280e8e9f1,CN=Operations,CN=DomainUpdates,CN=System,DC=testlab,DC=local" , null, null, Label.Base), new("CN=Microsoft,CN=Program Data,DC=testlab,DC=local", null, null, Label.Base), new("CN=Operations,CN=DomainUpdates,CN=System,DC=testlab,DC=local", null, null, Label.Base), new("CN=User,CN={C52F168C-CD05-4487-B405-564934DA8EFF},CN=Policies,CN=System,DC=testlab,DC=local", null, null, Label.Base), //This is a real object in our mock new("CN=Users,DC=testlab,DC=local", null, "ECAD920E-8EB1-4E31-A80E-DD36367F81F4", Label.Container), //This object does not exist in our mock new("CN=Users,DC=testlab,DC=local", null, "ECAD920E-8EB1-4E31-A80E-DD36367F81FD", Label.Container), //Test null objectid new("CN=Users,DC=testlab,DC=local", null, null, Label.Container) }; mock.Setup(x => x.QueryLDAP(It.IsAny <string>(), It.IsAny <SearchScope>(), It.IsAny <string[]>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <bool>())).Returns(searchResults); var processor = new ContainerProcessor(mock.Object); var test = processor.GetContainerChildObjects(_testGpLinkString).ToArray(); var expected = new TypedPrincipal[] { new() { ObjectIdentifier = "ECAD920E-8EB1-4E31-A80E-DD36367F81F4", ObjectType = Label.Container } }; Assert.Single(test); Assert.Equal(expected, test); }