1

In my application I want to ensure the user inserted a valid domain, username and password before attempting to impersonate with these details.

For this I used PrincipalContext.ValidateCredentials or the function here : http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C#35. However I see that if I enter the username and password of a user from another domain (that has trust relationship with the domain I enter) I get a positive result, this is bad since I get an exception when I try to impersonate using this domain+user+password combination.

This means I need to know if the user is part of the domain before I check if his username+password are valid. I tried to use UserPrincipal.FindByIdentity that is mentioned here Check if user is a Domain User or Local User but it seems to fall into the same problem, it returns true even if the user is not part of that specific domain.

To make it easier consider the following, there are 2 domains (that trust each other) and 1 user in each:

Domain1\User1

Domain2\User2

I need a function that will return false if I input: Domain1 and User2

Note: If you bump into this: ValidateCredentials returns true for unknown user? I already checked and the guest account is not enabled

Community
  • 1
  • 1

0 Answers0