AD lookup of GetGroup will return exception after migration to .net 9
Description
We are using AD on premises as identity system on Windows machines After migrating to .net 9 we see exceptions in lookup of roles in AD
Invalid URI: The hostname could not be parsed.'
Reproduction Steps
These 4 lines will recreate the problem
using var domain = new PrincipalContext(ContextType.Domain); using var user = UserPrincipal.FindByIdentity(domain, Environment.UserName); var groups = user?.GetGroups(); Console.WriteLine(string.Join($"{Environment.NewLine}", groups));
This will fail when referencing this version of AD libs
<ItemGroup>
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="9.0.0" />
</ItemGroup>
When referencing .net 8 it works fine
<ItemGroup>
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="8.0.0" />
</ItemGroup>
Expected behavior
Return of roles for user
Actual behavior
Exception Invalid URI: The hostname could not be parsed.'
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
Tagging subscribers to this area: @dotnet/area-system-directoryservices, @jay98014 See info in area-owners.md if you want to be subscribed.
Getting the same exception here.
Work around explained here: https://github.com/dotnet/runtime/issues/109858
Duplicate of https://github.com/dotnet/runtime/issues/109858