Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Remove redundant branch and store in DirectorySearcher #40321

Merged
merged 1 commit into from
Aug 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -623,17 +623,7 @@ public SearchResult FindOne()

private SearchResultCollection FindAll(bool findMoreThanOne)
{
searchResult = null;

DirectoryEntry clonedRoot = null;
if (_assertDefaultNamingContext == null)
{
clonedRoot = SearchRoot.CloneBrowsable();
}
else
{
clonedRoot = SearchRoot.CloneBrowsable();
}
DirectoryEntry clonedRoot = SearchRoot.CloneBrowsable();

UnsafeNativeMethods.IAds adsObject = clonedRoot.AdsObject;
if (!(adsObject is UnsafeNativeMethods.IDirectorySearch))
Expand Down Expand Up @@ -667,16 +657,16 @@ private SearchResultCollection FindAll(bool findMoreThanOne)

IntPtr resultsHandle;
if (properties != null)
{
adsSearch.ExecuteSearch(Filter, properties, properties.Length, out resultsHandle);
}
else
{
adsSearch.ExecuteSearch(Filter, null, -1, out resultsHandle);
properties = Array.Empty<string>();
}

SearchResultCollection result = new SearchResultCollection(clonedRoot, resultsHandle, properties, this);
searchResult = result;
return result;
return new SearchResultCollection(clonedRoot, resultsHandle, properties, this);
}

private unsafe void SetSearchPreferences(UnsafeNativeMethods.IDirectorySearch adsSearch, bool findMoreThanOne)
Expand Down