Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect definition of LSA_FOREST_TRUST_RECORD in System.DirectoryServices #68274

Merged
merged 2 commits into from
Apr 21, 2022

Conversation

elinor-fung
Copy link
Member

@elinor-fung elinor-fung commented Apr 20, 2022

Fixes #68240

Switch LSA_FOREST_TRUST_DOMAIN_INFO and LSA_FOREST_TRUST_BINARY_DATA to be structs as well.

Added a test that just loads all types in System.DirectoryServices.

Manually ran:

Forest forest = Forest.GetCurrentForest();
foreach (var t in forest.GetAllTrustRelationships())
{
    if (t is ForestTrustRelationshipInformation f)
    {
        Console.WriteLine("TopLevelNames");
        foreach (var name in f.TopLevelNames)
        {
            Console.WriteLine($"  {((TopLevelName)name).Name}");
        }
        Console.WriteLine("ExcludedTopLevelNames");
        foreach (string name in f.ExcludedTopLevelNames)
        {
            Console.WriteLine($"  {name}");
        }
        Console.WriteLine("TrustedDomainInformation");
        foreach (var info in f.TrustedDomainInformation)
        {
            Console.WriteLine($"  {((ForestTrustDomainInformation)info).DnsName}");
        }
    }
}

cc @AaronRobinsonMSFT @jkoritzinsky I broke this back in December when we were switching things to the p/invoke source generator

@ghost
Copy link

ghost commented Apr 20, 2022

Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #68240

Added a test that just loads all types in System.DirectoryServices.

Manually ran:

Forest forest = Forest.GetCurrentForest();
foreach (var t in forest.GetAllTrustRelationships())
{
    if (t is ForestTrustRelationshipInformation f)
    {
        Console.WriteLine("TopLevelNames");
        foreach (var name in f.TopLevelNames)
        {
            Console.WriteLine($"  {((TopLevelName)name).Name}");
        }
        Console.WriteLine("ExcludedTopLevelNames");
        foreach (string name in f.ExcludedTopLevelNames)
        {
            Console.WriteLine($"  {name}");
        }
        Console.WriteLine("TrustedDomainInformation");
        foreach (var info in f.TrustedDomainInformation)
        {
            Console.WriteLine($"  {((ForestTrustDomainInformation)info).DnsName}");
        }
    }
}
Author: elinor-fung
Assignees: -
Labels:

area-System.DirectoryServices

Milestone: -

@elinor-fung elinor-fung requested a review from a team April 20, 2022 16:16
[Fact]
public void TestGetAllTypes()
{
Type[] allTypes = typeof(DirectoryEntry).Assembly.GetTypes();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether it would be possible (later) to write a test that did this for each of our implementation assemblies, without actually pasting in the test into every one.

Something like - a common file that was included in all test assemblies, with a test that enumerated all loaded assemblies and did GetTypes on them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opened #68341 to track trying to do something like this.

@elinor-fung elinor-fung merged commit 0f98974 into dotnet:main Apr 21, 2022
@elinor-fung elinor-fung deleted the fix68240 branch April 21, 2022 17:38
@ghost ghost locked as resolved and limited conversation to collaborators May 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Assembly.GetTypes fails on System.DirectoryServices assembly
4 participants