[ There are a number of related posts, but none seem to explain what is going on ]
I am finding strange behavior with PrincipalContext.ValidateCredentials The basic question is "what should the username be?"
- user@domain (user principal name)
- domain\user (down level name)
- user (samAccountName)
For a while I was using the UserPrincipalName. Then I discovered that if the user has a UPN suffix (user@xyz.com where xyz.com is a UPN suffix in the domain), that ValidateCredentials failed.
Since I had a UserPrincipal, I just changed the code to pass in the SamAccountName. The SamAccoundName is globally unique in the domain, so this worked fine regardless of the UserPrincipalName.
But now, I see that if the ContextOptions.SimpleBind is used, the use of the SamAccountName no longer works.
According the the documentation of the function: The userName argument must take the form username (for example, mcampbell) rather than domain\username or username@domain.
Can anyone explain this behavior? What is really the "correct" way to validate a user/password given a UserPrincipal and a password?