dotnet-api-docs icon indicating copy to clipboard operation
dotnet-api-docs copied to clipboard

DirectorySearcher.FindOne throws exception when search string is not formatted properly.

Open deepakbansal-nith opened this issue 1 year ago • 2 comments

I specified Searcher.Filter = ((objectClass=user)(SAMAccountName=09433923)). I forgot to add an & before objectClass Filter. I kept getting "The directory service is unavailable" exception when Searcher.FindOne() method was called. As soon as I added the & and set the searcher to Search.Filter = (&(objectClass=user)(SAMAccountName=09433923)) , it worked. I did not expect an exception to happen if the search string was invalid. I was expecting a null result potentially.

deepakbansal-nith avatar Jun 25 '24 05:06 deepakbansal-nith