-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
PrincipalContext.ValidateCredentials(null, null) does not use credentials supplied in the contructor #26009
Comments
I wonder what is the behavior on .NET Framework? Is it same, or does it do what documentation says? |
The documentation is incorrect. If NULL as passed as username and password the credentials of the current process are validated. .NET core and .NET framework behave the same. |
Should we fix the docs then? It is simple - just hit edit button on the linked docs page and submit PR. |
Opened PR with changes dotnet/dotnet-api-docs#92 |
Thanks folks. |
I just happened to look at this again today, and I realized that the updates made back in April weren't entirely accurate. Right now, it reads like this:
It still makes reference to the "credentials specified in the constructor". In reality, the credentials specified in the constructor make no difference to this method. It should read something like this:
|
@gabeluci can you please submit changes directly against docs repo? (there is edit button on doc pages) |
Sure, I've added dotnet/dotnet-api-docs#580 |
I closing this as it looks the issue is addressed. let's know if this is not the case. |
This came from a question on Stackoverflow: https://stackoverflow.com/questions/50055073/testing-a-principalcontext-using-validatecredentialsnull-null-behaves-une
The documentation of
PrincipalContext.ValidateCredentials(String, String)
says:However, this is not what actually happens. It seems to use the default credentials of the running process, rather than the credentials supplied in the constructor of
PrincipalContext
.This can be replicated by running a project under credentials that are untrusted on your domain (like a local computer account) then using this code:
Where "username" and "password" are valid on the domain, of course. After this,
valid
comes out to befalse
.I enabled .NET code debugging and found that the credentials passed in the constructor are never passed along during
ValidateCredentials
. Instead, thenull
values are passed along (which are then turned into empty strings once they're fed intoNetworkCredential
).However, if I run the process under domain credentials, then
ValidateCredentials
succeeds.The text was updated successfully, but these errors were encountered: