public void TestSync( ) { DBHelper.Init(Settings.Default.ConnectionString); DBHelper.ExecuteNonQuery("Test_DeleteAllData"); IList <ADPrincipal> pl = GetPrincipalList( ); ADSyncHelper.SyncAdToSqlServer(pl, Settings.Default.ConnectionString, "TestAD"); IAuthorizationManager manager = Afcas.GetAuthorizationManager( ); using (new ObjectCacheScope( )) { Assert.AreEqual(5, manager.GetPrincipalList( ).Count); //removal from sql side should not matter manager.RemovePrincipal("p1"); ADSyncHelper.SyncAdToSqlServer(pl, Settings.Default.ConnectionString, "TestAD"); Assert.AreEqual(5, manager.GetPrincipalList( ).Count); } using (new ObjectCacheScope( )) { //removal from ad side ADPrincipal p1 = pl[0]; pl.RemoveAt(0); ADSyncHelper.SyncAdToSqlServer(pl, Settings.Default.ConnectionString, "TestAD"); IList <Principal> dbpl = manager.GetPrincipalList( ); Assert.AreEqual(4, dbpl.Count); Assert.That(!IsInList(p1.Name, dbpl)); Assert.That(!manager.IsMemberOf("g1", "p1")); } }
private static void Main(string[] args) { try { IList <ADPrincipal> pl = ADHelper.FetchADPrincipals(Settings.Default.LdapPathList); ADSyncHelper.SyncAdToSqlServer(pl, Afcas.Properties.Settings.Default.ConnectionString, Settings.Default.PrincipalSourceName); } catch (Exception ex) { Console.WriteLine("{0}: Error while running ADSync: {1}", DateTime.Now.ToString("F"), ex.Message); Environment.Exit(1); } }