dotnet / dotnet/dotnet-api-docs

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

Open
#10,059 2 comments 0 reactions 0 assignees View on GitHub
area-System.DirectoryServices Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.