Skip to content

Broken DirectorySearch DirectorySynchronization #79066

Closed

Description

@somescout

Description

Commit d15adf0 broken DirectorySynchronization in DirectorySearch by following change in DirectorySearch.cs:

/// FROM
            SearchResultCollection result = new SearchResultCollection(clonedRoot, resultsHandle, properties, this);
            searchResult = result; /// !!!REMOVED!!!
            return result;
/// TO
            return new SearchResultCollection(clonedRoot, resultsHandle, properties, this);

searchResult is not cached now and because of that the directory synchronization cookie is not updated.

Reproduction Steps

            var ds = new DirectorySearcher("LDAP://srv-dc/dc=domain,dc=local");

            ds.Filter = "(|(&(objectCategory=person)(objectClass=user))(&(objectClass=group)(!(groupType:1.2.840.113556.1.4.803:=2147483648)))(isDeleted=*))";

            ds.DirectorySynchronization = new DirectorySynchronization();
            ds.Tombstone = true;

            ds.PropertiesToLoad.Add("objectGUID");
            ds.PropertiesToLoad.Add("isDeleted");

            ds.PropertiesToLoad.Add("objectClass");

            ds.PropertiesToLoad.Add("member");
            ds.PropertiesToLoad.Add("mail");
            ds.PropertiesToLoad.Add("name");

            var res1 = ds.FindAll();
            var res2 = ds.FindAll();

Expected behavior

res2 should be empty

Actual behavior

res2 is identical to res1

Regression?

Commit d15adf0 introduced regression.

Known Workarounds

Set searchResult private field after search via reflection, I assume.

Configuration

NET 6.0
Windows 10 22H2
x64

Other information

d15adf0

Activity

  1. ghost added
    untriaged
    on Dec 1, 2022
  2. changed the title [-]Broken DirectorySearch[/-] [+]Broken DirectorySearch DirectorySynchronization[/+] on Dec 1, 2022
  3. marek-safar commented on Dec 1, 2022

    @marek-safar
    Contributor
  4. stephentoub commented on Dec 1, 2022

    @stephentoub
    Member

    Ugh. This is why naming conventions matter.

  5. self-assigned this
    on Dec 1, 2022
  6. ghost added
    in-pr
    on Dec 1, 2022
  7. ghost removed
    in-pr
    on Dec 1, 2022
  8. ghost removed
    untriaged
    on Dec 1, 2022
  9. ghost locked as resolved and limited conversation to collaborators on Dec 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions