none
Sync Provider for Active Directory RRS feed

  • Question

  • Hi Guys,

    I need ideas how to build sync solution for a db provider and Active Directory. Sync is focused on creating security groups, user accounts (maybe org. units). Requirement is not to couple with any specific source provider. Sync should be one way, destination will be always AD with the same subset of attributes. What in your opinion mechanism in Sync Frameworh should be used. E.g. can I mix DbSyncProvider with custom provider. If I'm going to map multile tables in sync proces should I use Standard Custom Provider both for AD and db side? How to map attributes between source and destination. Is it enough to use Sync classes to translate source to dest. et.c

    Cheers,
    Eryk
    Eryk
    Saturday, February 20, 2010 7:29 PM

Answers

  • The solution is possible - when the source is a DbSyncProvider (suporting ADO.NET data sources) and the target is a Standard Custom Provider.

    However there is some effort from the DbSyncProvider side.
    1. You need to define a data retrieve class which contains all the Changed Data from the source database side.
    2. You need to implement a Standard Custom Provider to comsume all changes from the source and apply these changes to the ActiveDirectory.
    3. On the source side, instead of using DbSyncProvider directly, you need to extend it and override the GetChangeBatch() method in the child class.
    4. The GetChangeBatch() in the child class (from #3) needs to do a few actions.
      a. Call GetChangeBatch from the base class. So that all changes are enumerated in the ADO.NET dataset object (the 3rd parameter of GetChangeBatch() ).
      b. Go through all data rows from the dataset and put all non-deleted row data to the DataRetrieve object in step #1.
      c. Construct a new ChangeBatch object. 
        1. For each ItemChange, the sync id should be the database row PK (a GUID)  + table name.
        2. ItemChange CreationVersion - should be column value of DbSyncSession.SyncCreatePeerKey and DbSyncSession.SyncCreatePeerTimestamp of each dataRow.
        3. ItemChange UpdateVersion - should be column value of DbSyncSession.SyncUpdatePeerKey, DbSyncSession.SyncUpdatePeerTimestamp of each dataRow.
        4. For deleted rows, you need to do RejectChanges() to see its Id and other PeerKey/PeerTimestamp to construct the metadata.
        5. From the DataRowState of each dataRow, you can decide the ChangeKind of each ItemChange.
        6. Set IsLastBatch when the change batch from the base class is true.

    All our efforts here is to make the destination provider "thinks" the source provider is also a standard custom provider.

    Please give a try.

    Thanks.


    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Jesse L - MSFT Friday, March 5, 2010 7:19 PM
    • Marked as answer by ErykG77 Saturday, March 6, 2010 2:10 PM
    Wednesday, March 3, 2010 8:02 AM
    Answerer

All replies

  • Suggest you looking at a Sync101 sample about Simple Provider, http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3414.  You probably need to implement 2 providers yourself, so please look at the sample from the above link.  The source provider is a DB provider which is doing EnumerateItems.  The destination provider is a AD provider which is doing InsertItem, UpdateItem and DeleteItem.

    Thanks.
    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by Yunwen BaiModerator Tuesday, February 23, 2010 9:08 AM
    • Unmarked as answer by ErykG77 Saturday, February 27, 2010 11:25 PM
    Monday, February 22, 2010 7:19 PM
    Answerer
  • Hi Leo,
    Thanks for your answer. Additional question is , can I mix DbSyncProvider with simple custom provider? For AD my understanding is that best option to keep metadata is to store in a database. And another one. Can I use single simple custom provider to sync more than one table (e.g. 3 one by one) in one sync session?
    Thanks,
    Eryk
    Eryk
    Monday, February 22, 2010 10:25 PM
  • unfortunately no for both.

    thanks
    Yunwen
    This posting is provided "AS IS" with no warranties, and confers no rights.
    • Marked as answer by ErykG77 Tuesday, February 23, 2010 9:25 AM
    • Unmarked as answer by ErykG77 Thursday, February 25, 2010 12:14 AM
    Tuesday, February 23, 2010 9:08 AM
    Moderator
  • Hi,
    Sorry bit one more question. Can I mix DbSyncProvider for an ADO.NET with Standard Custom provider which I would create for AD?
    Thanks,
    Eryk
    Eryk
    Thursday, February 25, 2010 12:16 AM
  • The DbSyncProvider for ADO.NET works in a different way from the Custom Provider (from the simply sync provider).  So you may not mix them in the same sync session.

    Thanks.

    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    Sunday, February 28, 2010 6:03 PM
    Answerer
  • HI,
    Not sure if I was clear what I need to do in last response.

    What I meant is to join DbSyncProvider (Database Collaboration scenarios supporting ADO.NET data sources) and Standard Custom Provider (not the simple provider). I noticed both of those two provider classes must derive from the same base classes and interfaces so I hope it could work. Any experience with that or at least suggestions with yes/no answer?

    Cheers,
    Eryk
    Eryk
    Sunday, February 28, 2010 9:08 PM
  • The solution is possible - when the source is a DbSyncProvider (suporting ADO.NET data sources) and the target is a Standard Custom Provider.

    However there is some effort from the DbSyncProvider side.
    1. You need to define a data retrieve class which contains all the Changed Data from the source database side.
    2. You need to implement a Standard Custom Provider to comsume all changes from the source and apply these changes to the ActiveDirectory.
    3. On the source side, instead of using DbSyncProvider directly, you need to extend it and override the GetChangeBatch() method in the child class.
    4. The GetChangeBatch() in the child class (from #3) needs to do a few actions.
      a. Call GetChangeBatch from the base class. So that all changes are enumerated in the ADO.NET dataset object (the 3rd parameter of GetChangeBatch() ).
      b. Go through all data rows from the dataset and put all non-deleted row data to the DataRetrieve object in step #1.
      c. Construct a new ChangeBatch object. 
        1. For each ItemChange, the sync id should be the database row PK (a GUID)  + table name.
        2. ItemChange CreationVersion - should be column value of DbSyncSession.SyncCreatePeerKey and DbSyncSession.SyncCreatePeerTimestamp of each dataRow.
        3. ItemChange UpdateVersion - should be column value of DbSyncSession.SyncUpdatePeerKey, DbSyncSession.SyncUpdatePeerTimestamp of each dataRow.
        4. For deleted rows, you need to do RejectChanges() to see its Id and other PeerKey/PeerTimestamp to construct the metadata.
        5. From the DataRowState of each dataRow, you can decide the ChangeKind of each ItemChange.
        6. Set IsLastBatch when the change batch from the base class is true.

    All our efforts here is to make the destination provider "thinks" the source provider is also a standard custom provider.

    Please give a try.

    Thanks.


    Leo Zhou ------ This posting is provided "AS IS" with no warranties, and confers no rights.
    • Proposed as answer by Jesse L - MSFT Friday, March 5, 2010 7:19 PM
    • Marked as answer by ErykG77 Saturday, March 6, 2010 2:10 PM
    Wednesday, March 3, 2010 8:02 AM
    Answerer
  • I'll add that you should be able to use a SimpleSyncProvider on the destination side without changing Leo's steps.

    -Jesse
    Friday, March 5, 2010 7:20 PM
  • HI Guys,

    Sorry to get back to this. One more question but I think it can be usefull for few folks here. How to deal with different PK ids types at db side an AD side. At dbside(source) it is Int, BigInt or whatever and on destination(AD) it seems to be guid (general rule is that source and destination idetifiers are of different types). Do I need to store this Int<->guid in my metadata at destination side? What about IdFormats property used in all examples. Doc says if IdFormat property in BeginSession call determine that source and destination providers has different IdFormats, sync sesion will fail (not sure IdFormats is right name but I took feew beers now so not really sure about naming convention  ;) ).

    Thanks,
    Eryk


    Eryk
    Friday, April 30, 2010 9:27 PM