diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs index 1ef524342a335..37f2018d70bc6 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectorySearcher.cs @@ -607,6 +607,8 @@ public DirectoryVirtualListView? VirtualListView private SearchResultCollection FindAll(bool findMoreThanOne) { + searchResult = null; + DirectoryEntry clonedRoot = SearchRoot!.CloneBrowsable(); UnsafeNativeMethods.IAds adsObject = clonedRoot.AdsObject; @@ -650,7 +652,9 @@ private SearchResultCollection FindAll(bool findMoreThanOne) properties = Array.Empty(); } - return new SearchResultCollection(clonedRoot, resultsHandle, properties, this); + SearchResultCollection result = new SearchResultCollection(clonedRoot, resultsHandle, properties, this); + searchResult = result; + return result; } private unsafe void SetSearchPreferences(UnsafeNativeMethods.IDirectorySearch adsSearch, bool findMoreThanOne)