dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.32k stars 4.74k forks source link

Group lookup fails if first Global Catalog server is down #29181

Open dbaileyut opened 5 years ago

dbaileyut commented 5 years ago

There appears to be a bug with Global Catalog discovery/error handling in System.DirectoryServices.AccountManagement

If the "first" Global Catalog in an Active Directory site is unavailable, calling System.DirectoryServices.AccountManagement.Principal.GetGroups() results in an error.

It appears to be related to the code block at https://github.com/dotnet/corefx/blob/a6f76f4f620cbe74821c6445af3f13e048361658/src/System.DirectoryServices.AccountManagement/src/System/DirectoryServices/AccountManagement/AD/ADStoreCtx.cs#L1207-L1215

since it gets all the GCs and tests their names without confirming they're available. If the first one succeeds, it breaks out.

See attached stack trace and rough test code. StackTrace.txt Replication-CSTest.txt

dbaileyut commented 5 years ago

Note: the first server returned "gg" must be unreachable in your test environment.