Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetDirectorySynchronizationCookie() returns empty cookie #49376

Closed
EvanMulawski opened this issue Mar 9, 2021 · 14 comments
Closed

GetDirectorySynchronizationCookie() returns empty cookie #49376

EvanMulawski opened this issue Mar 9, 2021 · 14 comments

Comments

@EvanMulawski
Copy link

Description

System.DirectoryServices.DirectorySynchronization.GetDirectorySynchronizationCookie() returns an invalid, 0-byte cookie on net5.0. A valid cookie is returned when running the same code on netcoreapp3.1.

Repro: https://github.com/EvanMulawski/DotNetDirectoryServicesDirSyncIssue

Configuration

  • net5.0 (5.0.3)
  • Windows 10 64-bit 1909

Regression?

Works in:

  • netcoreapp3.1 (3.1.12)
  • .NET Framework 4.8
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Mar 9, 2021
@ghost ghost added this to Needs triage in Triage POD for Meta, Reflection, etc Mar 10, 2021
@joperezr joperezr moved this from Needs triage to Jose's triage backlog in Triage POD for Meta, Reflection, etc Mar 31, 2021
@Thomas-Avery
Copy link

I am experiencing the same 0-byte cookie problem; however, it seems isolated to the version of System.DirectoryServices not net5.0 vs netcoreapp3.1.

Target Framework Runtime System.DirectoryServices NuGet Package Version Result
netcoreapp3.1 3.1.14 5.0.0 FAIL
netcoreapp3.1 3.1.14 4.7.0 PASS
net5.0 5.0.5 5.0.0 FAIL
net5.0 5.0.5 4.7.0 PASS

@Thomas-Avery
Copy link

After some more research it looks like in the past the DirectorySearcher class, in the FindAll() private method, it would set an internal SearchResultCollection searchResult property.

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

This internal searchResult property is what is used to set the DirsyncCookie when you call directorySearcher.DirectorySynchronization.

// if user specifies dirsync search preference and search is executed
if (directorySynchronizationSpecified && searchResult != null)
{
_sync!.ResetDirectorySynchronizationCookie(searchResult.DirsyncCookie);
}
return _sync;

Now in the FindAll() code it just returns a new SearchResultCollection without populating the internal searchResult property. Which I believe is the root of the problem.

return new SearchResultCollection(clonedRoot, resultsHandle, properties, this);

@joperezr joperezr added bug and removed untriaged New issue has not been triaged by the area owner labels May 13, 2021
@joperezr joperezr added this to the 6.0.0 milestone May 13, 2021
@joperezr joperezr moved this from Jose's triage backlog to v-Next in Triage POD for Meta, Reflection, etc May 13, 2021
@krwq krwq moved this from v-Next to Jose's triage backlog in Triage POD for Meta, Reflection, etc Jul 15, 2021
@joperezr
Copy link
Member

joperezr commented Aug 5, 2021

@Thomas-Avery thanks for the great investigation! Have you had a chance to revert that change to again set searchResult property and validate that this fixes the issue you are facing?

@joperezr
Copy link
Member

cc: @tquerec @grubioe Do you mind taking a look at this one since it is in S.DS?

@joperezr
Copy link
Member

I don't think that we'll get to fix this in 6.0.0 so moving it to 7.0.0 for now.

@joperezr joperezr modified the milestones: 6.0.0, 7.0.0 Aug 16, 2021
@joperezr joperezr moved this from Jose's triage backlog to Future in Triage POD for Meta, Reflection, etc Aug 16, 2021
@arora-kushal
Copy link

The same error is happening for:

Target Framework : net 5.0/netcoreapp3.1
Runtime : 5.0.13 (SDK - 5.0.404)
System.DirectoryServices NuGet Package Version: 4.7.0
Result: FAIL

Workaround: I have used FindOne() method, instead of FindAll() to get cookie.

@ghost ghost moved this from Future to Needs triage in Triage POD for Meta, Reflection, etc Dec 28, 2021
@ghost ghost added the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Dec 28, 2021
@joperezr joperezr removed the needs-further-triage Issue has been initially triaged, but needs deeper consideration or reconsideration label Jan 25, 2022
@knoxi
Copy link

knoxi commented Jun 7, 2022

+1
run into the same on .net 6, had to rollback System.DirectoryServices to 4.7.0 to get it working again

@joperezr
Copy link
Member

@knoxi did the workaround provided above by @arora-kushal not work for you?

@knoxi
Copy link

knoxi commented Jun 30, 2022

@joperezr I didn't tried this one, since I'm not sure if the behavior is still the same when using FindOne() instead of FindAll() because I'm using a query with FindAll(). Maybe I should give it a try.

@joperezr joperezr modified the milestones: 7.0.0, Future Jul 18, 2022
@hrrrrustic
Copy link
Contributor

This was fixed by #79093, could be closed

@buyaa-n
Copy link
Member

buyaa-n commented May 8, 2023

Yep, it is fixed and the fix ported to 6.0/7.0

@buyaa-n buyaa-n closed this as completed May 8, 2023
@hrrrrustic
Copy link
Contributor

@buyaa-n I found one more similar issue #59756 that can be closed

@buyaa-n
Copy link
Member

buyaa-n commented May 9, 2023

Thanks, leaving the issue open for adding a test

@dotnet dotnet locked as resolved and limited conversation to collaborators Jun 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

8 participants