Reputation: 3957
Question: Is it possible to add an item to SearchResultCollection? Or is there a potential work around?
Project requirement: Get all objects and specific data along with all object group members (to be represented as GroupGuid and MemberGuid pairs).
Problem: I have identified a race condition in a program that retrieves all objects and an object's group members. The question is how best to handle it? The best I can think of is to get two SearchResultCollections (SRC).
For all objects in srcObjects, I can retrieve all properties that I need while also adding the objectGUID and distinguishedName to a dictionary. I can run a loop over the srcGroups collection, which will return distinguishedNames. Then, while retrieving the objectGUID from the dictionary, I can test to see if it exists. If it does not, then a new object has been added while the program is running (i.e., race condition). I would like to add the new object into the srcObjects collection. This should solve the race condition while also allowing me to retrieve the new object's properties.
Once all of the group members have been retrieved, I can then loop over the srcObjects collection and ensure that all objects that are in the srcGroups collection are also in the srcObjects collection.
Upvotes: 0
Views: 207
Reputation: 40988
Is it possible to add an item to SearchResultCollection?
The short answer is no. SearchResultCollection
only implements ICollection
, which doesn't require any methods to add items, and indeed, SearchResultCollection
doesn't provide any methods to add anything.
The only work around is to enumerate the collection and convert each item to another type of object, added to a List
of that type.
Upvotes: 1