Sorry if this is not posted in the right location.
I have a feeling there is a better way to do this. If so, I'm all ears. Anyway, I want to search for an AD user with and without a space in their name because sAMAccount names can be either format.
This code:
1)search for name with space
2) if 1 errors: search for name without space
3) if 2 errors: do things when the user is not found by either search method like add the user.
even when the user is found, the code always executes the 2nd catch block, giving me an "ADUserAlreadyExists" exception. I wouldn't expect this because the 2nd catch should only execute if the 2nd try encounters an error. I think it has to do with both catches being for the same error name.