I have an Active Directory synchronization tool (.NET 2.0 / C #) written as a Windows service that I have been working on for some time, and recently I was tasked with adding the ability to manage events based on changes in group memberships. The main scenario is that users are synchronized with the security database, and when changing the group membership, users need to change access rights (that is, if I am a member of the "IT staff" now, then I should automatically access the server room, if I remove from this group, then I should automatically lose access to the server room).
The problem is that when you perform DirectorySynchronization against groups, you get back the group from which the member was added / deleted, and from there, when you grab the list of members, you return a list of all the members of this group, not just the members that were added or deleted. This leads me to a rather effective problem - because in order to find out if the user has been added or deleted, I will have to locally save the list of each group and all members and compare them with the current list to find out who was added (not to the local list ) and who was deleted (in the local list, not in the list of current members).
I only discuss saving the details of the group membership in the DataSet in memory and writing to disk every time I handle new membership changes. Thus, if the service stops / crashing or rebooting the computer, I can still go to the current Active Directory state in the security database by comparing the latest information on the disk with the current list of group members. However, this seems terribly ineffective - through each member of the group, compare with what is in the data set, and then write the changes to disk every time there are changes in the list.
Has anyone dealt with this scenario before? Is there a way that I have not found to get only the delta of the group members? What would you do in this situation to ensure that you never miss any changes while doing the least performance?
Edit: AD can contain 500 users, it can contain 200,000 users - it depends on the client, and besides how many groups the average user is a member
source share