ValidateCredentials returns true for unknown user?

后端 未结 3 1571
别那么骄傲
别那么骄傲 2020-12-06 02:26

I\'m seeing some odd behaviour here using PrincipalContext.ValidateCredentials. The set-up is two Active Directory domains in parent/child setup (so we have pri

相关标签:
3条回答
  • 2020-12-06 02:56

    Some amount of googling later (not that I've been in and out of google all day trying to find this anyway), I've found the answer.

    Put simply, if the Guest account is enabled in the domain, ValidateCredentials will return TRUE for an unknown user. I've just checked the status of the guest user in development.company.com, and sure enough the account is enabled. If I have the guest account disabled, ValidateCredentials correctly returns false.

    This is a fairly fundamental gotcha, not sure I'm keen on this behaviour... pity it's not explicitly mentioned on MSDN.

    0 讨论(0)
  • 2020-12-06 02:58

    I have used ContextOptions.SimpleBind flag with ValidateCredentials it solved my problem..

    Sample code:

        using (var context = new PrincipalContext(ContextType.Domain, "DOMAIN", null))
        {
            bool loginResult = context.ValidateCredentials(username, password, ContextOptions.SimpleBind); // returns false for unknown user
        }
    
    0 讨论(0)
  • 2020-12-06 03:09

    Could it be related to this:

    The ValidateCredentials method binds to the server specified in the constructor. If the username and password parameters are null, the credentials specified in the constructor are validated. If no credential were specified in the constructor, and the username and password parameters are null, this method validates the default credentials for the current principal.

    0 讨论(0)
提交回复
热议问题