Skip to content

System.DirectoryServices.AccountManagement Version 9.0: UserPrincipal.GetAuthorizationGroups() throws System.UriFormatException: Invalid URI: The hostname could not be parsed. #109858

@uwer62

Description

@uwer62

Description

After updating from 8.0.1 to 9.0.0 the call above throws the following exception:
System.UriFormatException: Invalid URI: The hostname could not be parsed.

Reproduction Steps

var ctx = new PrincipalContext(ContextType.Domain);
var usersearcher = new PrincipalSearcher(new UserPrincipal(ctx));
var users = usersearcher.FindAll().Cast<UserPrincipal>();
var user = users.FirstOrDefault(e => e.SamAccountName == "valid user name");
var groupList = user?.GetAuthorizationGroups().ToList(); <== throws in 9.0.0

Expected behavior

This call should return the groups as the older versions

Actual behavior

Throws unexpected exception

Regression?

Yes. worked in 8.0.1

Known Workarounds

downgrade to 8.0.1

Configuration

.NET 8.0 and .NET 9.0 on Windows 11

Other information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions