Skip to content

DirectoryVirtualListView.ApproximateTotal always returning zero for .NET Core #47169

Description

@ben-falconer

Description

After performing a search with the System.DirectoryServices.DirectorySearcher using a VirtualListView, the VirtualListView.ApproximateTotal value is always returning as 0 even in cases where there should be results.

Example code:

using (var searcher = new DirectorySearcher())
{
searcher.SearchRoot = new DirectoryEntry() { Path = $"GC://DC=jedi,DC=com" };
searcher.Filter = $"(objectCategory=user)";
searcher.Sort = new SortOption("cn", SortDirection.Ascending);
searcher.PropertiesToLoad.Add("objectSid");
searcher.VirtualListView = new DirectoryVirtualListView(0, 15, 1);
var users = searcher.FindAll().OfType<SearchResult>();
foreach (var user in users)
{
var sidProperty = user.Properties["objectSid"];
if (sidProperty.Count > 0)
{
var sidBytes = (byte[])(sidProperty[0]);
Console.WriteLine(new SecurityIdentifier(sidBytes, 0).ToString());
}
};
// Approximate total always returns zero
Console.WriteLine($"Approximate Total = {searcher.VirtualListView.ApproximateTotal}");
}

Configuration

  • .NET Core 3.1
  • Windows Server 2016
  • x64

Not aware that the problem is specific to this configuration.

Regression?

Yes. The same code returns the expected ApproximateTotal value in a .NET Framework application

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions