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

System.DirectoryServices.AccountManagement 9.0.1 PrincipalContext.ValidateCredentials fails with a COM exception #111683

Open
tlencse opened this issue Jan 21, 2025 · 1 comment
Labels
area-System.DirectoryServices untriaged New issue has not been triaged by the area owner

Comments

@tlencse
Copy link

tlencse commented Jan 21, 2025

Description

With System.DirectoryServices.AccountManagement 9.0.1, PrincipalContext.ValidateCredentials with ContextType.Machine works only once for a user. Every subsequent call (even after restarting the application) fails with the following message

Multiple connections to a server or shared resource by the same user, using more than one user name, are not allowed. Disconnect all previous connections to the server or shared resource and try again. (Exception from HRESULT: 0x800704C3)
at System.DirectoryServices.AccountManagement.CredentialValidator.BindSam(String target, String userName, String password)
at System.DirectoryServices.AccountManagement.CredentialValidator.Validate(String userName, String password)
at System.DirectoryServices.AccountManagement.PrincipalContext.ValidateCredentials(String userName, String password)

It does not happen in version 9.0.0

Reproduction Steps

Write a console app with the code below, using package references

<PackageReference Include="System.DirectoryServices" Version="9.0.1" />
<PackageReference Include="System.DirectoryServices.AccountManagement" Version="9.0.1" />
using PrincipalContext pc = new PrincipalContext(ContextType.Machine, null);
pc.ValidateCredentials(someUserName, somePassword);

The app will run only once, all subsequent runs will give the above error

Expected behavior

The call should not fail on subsequent runs of the application

Actual behavior

It runs correctly once, and then never again until restarting the Workstation service.

Regression?

Yes, it works correctly with

    <PackageReference Include="System.DirectoryServices" Version="9.0.0" />
    <PackageReference Include="System.DirectoryServices.AccountManagement" Version="9.0.0" />

Known Workarounds

restarting the Workstation service, or using COM interop directly (haven't tried)

Configuration

.net 8
Windows 11 Pro, build 26100.2894 x64
I guess it is not specific to this config

Other information

I think it is exactly the same issue as #83269 but that one is already closed.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jan 21, 2025
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.DirectoryServices untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

1 participant