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_ReadContainerGPLinks_ReturnsCorrectValues() { var processor = new ContainerProcessor(new MockLDAPUtils()); var test = processor.ReadContainerGPLinks(_testGpLinkString).ToArray(); var expected = new GPLink[] { new() { GUID = "B39818AF-6349-401A-AE0A-E4972F5BF6D9", IsEnforced = false }, new() { GUID = "ACDD64D3-67B3-401F-A6CC-804B3F7B1533", IsEnforced = false }, new() { GUID = "C45E9585-4932-4C03-91A8-1856869D49AF", IsEnforced = false } }; Assert.Equal(3, test.Length); Assert.Equal(expected, test); }
public void ContainerProcessor_ReadContainerGPLinks_IgnoresNull() { var processor = new ContainerProcessor(new MockLDAPUtils()); var test = processor.ReadContainerGPLinks(null); Assert.Empty(test); }
public void ContainerProcessor_ReadContainerGPLinks_UnresolvedGPLink_IsIgnored() { var processor = new ContainerProcessor(new MockLDAPUtils()); //GPLink that doesn't exist const string s = "[LDAP://cn={94DD0260-38B5-497E-8876-ABCDEFG},cn=policies,cn=system,DC=testlab,DC=local;0]"; var test = processor.ReadContainerGPLinks(s); Assert.Empty(test); }