protected override void TestInitialize() { ldapAdapter = BaseTestSite.GetAdapter <ILdapAdapter>(); sutControlAdapter = BaseTestSite.GetAdapter <IDrsrSutControlAdapter>(); updateStorage = UpdatesStorage.GetInstance(); drsTestClient.Reset(); EnvironmentConfig.ExpectSuccess = true; base.TestInitialize(); }
public bool Invoke() { bool binded = false; try { if (client.DrsBind(server, EnvironmentConfig.User.ParentDomainAdmin, DRS_EXTENSIONS_IN_FLAGS.DRS_EXT_BASE) != 0) { return(false); } binded = true; ILdapAdapter ad = client.Site.GetAdapter <ILdapAdapter>(); ad.Site = client.Site; REPS_FROM[] reps = ad.GetRepsFrom((DsServer)EnvironmentConfig.MachineStore[server], srcNC); if (reps == null) { return(false); } DsServer s = (DsServer)EnvironmentConfig.MachineStore[src]; bool found = false; foreach (REPS_FROM rf in reps) { if (rf.uuidDsaObj == s.NtdsDsaObjectGuid) { found = true; break; } } if (found) { return(true); } if (0 == client.DrsReplicaAdd(server, DRS_MSG_REPADD_Versions.V1, s, DRS_OPTIONS.DRS_WRIT_REP, srcNC)) { return(true); } return(false); } catch { return(false); } finally { if (binded) { client.DrsUnbind(server); } } }
/// <summary> /// set ldap adapter /// </summary> public static void SetLdapAdapter(ILdapAdapter ad) { ldapAdapter = ad; }
/// <summary> /// load all infos /// </summary> /// <param name="site">PTD test site</param> public static void Initialize(ITestSite site) { if (site == null) { throw new ApplicationException("TestSite could not be NULL."); } //only initialize once if (dataLoaded) { if (!init_succeed) { site.Assert.Fail("EnvironmentConfig init failed in previous cases"); } return; } //try //{ testSite = site; ldapAd = site.GetAdapter <ILdapAdapter>(); ldapAd.Site = site; testDS = bool.Parse(site.Properties["MS_DRSR.TestDS"]); funcLv = (Microsoft.Protocols.TestTools.StackSdk.ActiveDirectory.Drsr.DrsrDomainFunctionLevel)(ADCommonServerAdapter.Instance(testSite).DomainFunctionLevel); UseKerberos = bool.Parse(site.Properties["MS_DRSR.UseKerberos"]); UseNativeRpcLib = bool.Parse(site.Properties["MS_DRSR.UseNativeRpcLib"]); //create normal user account if it does not exist yet string serverName = ADCommonServerAdapter.Instance(testSite).PDCNetbiosName; string serverPort = ADCommonServerAdapter.Instance(testSite).ADDSPortNum; string domainNC = "DC=" + ADCommonServerAdapter.Instance(testSite).PrimaryDomainDnsName.Replace(".", ",DC="); string parentDN = string.Format("CN=Users,{0}", domainNC); string userDN = string.Format("CN={0},CN=Users,{1}", DomainUserName, domainNC); string userPassword = ADCommonServerAdapter.Instance(testSite).DomainUserPassword; if (!Utilities.IsObjectExist(userDN, serverName, serverPort)) { Utilities.NewUser(serverName, serverPort, parentDN, DomainUserName, userPassword); } //please do all object intialization in this call following example InitUserObjects(); InitDomainObjects(); InitMachineObjects(); FinishUserObjects(); //load DS AppNC late due to rootDSE search issue if (testDS && !string.IsNullOrEmpty(AppNCDistinguishedName)) { ((AddsDomain)DomainStore[DomainEnum.PrimaryDomain]).OtherNCs = new DSNAME[1]; ((AddsDomain)DomainStore[DomainEnum.PrimaryDomain]).OtherNCs[0] = ldapAd.GetDsName((DsServer)MachineStore[Machine.WritableDC1], AppNCDistinguishedName).Value; } MainDC = (AddsServer)EnvironmentConfig.MachineStore[Machine.MainDC]; DsServer s1 = (DsServer)EnvironmentConfig.MachineStore[Machine.WritableDC1]; transport_obj = ldapAd.GetDsName( s1, "cn=ip,cn=inter-site transports,cn=sites," + LdapUtility.ConvertUshortArrayToString(s1.Domain.ConfigNC.StringName) ).Value; DsUser dcAccount = new DsUser(); dcAccount.Domain = s1.Domain; dcAccount.Username = s1.NetbiosName + "$"; dcAccount.Password = ADCommonServerAdapter.Instance(testSite).PDCPassword; UserStore.Add(User.MainDCAccount, dcAccount); //not always need dc2 if (EnvironmentConfig.MachineStore.ContainsKey(Machine.WritableDC2)) { DsServer s2 = (DsServer)EnvironmentConfig.MachineStore[Machine.WritableDC2]; DsUser dcAccount2 = new DsUser(); dcAccount2.Domain = s2.Domain; dcAccount2.Username = s2.NetbiosName + "$"; dcAccount2.Password = ADCommonServerAdapter.Instance(testSite).SDCPassword; UserStore.Add(User.WritableDC2Account, dcAccount2); } if (EnvironmentConfig.MachineStore.ContainsKey(Machine.RODC)) { DsServer rodc = (DsServer)EnvironmentConfig.MachineStore[Machine.RODC]; DsUser rodcAccount = new DsUser(); rodcAccount.Domain = rodc.Domain; rodcAccount.Username = rodc.NetbiosName + "$"; rodcAccount.Password = ADCommonServerAdapter.Instance(testSite).RODCPassword; UserStore.Add(User.RODCMachineAccount, rodcAccount); } //} //catch (Exception e) //{ // init_succeed = false; // site.Assert.Fail("data initialization failed due to exception:" + e.InnerException == null ? e.Message : e.InnerException.Message); //} //alwasy only init once dataLoaded = true; }