public static void ReplicateFromNeighbors(string targetServer, string partitionName) { try { // set a directory server context for the target server DirectoryContext targetContext = new DirectoryContext( DirectoryContextType.DirectoryServer, targetServer); // bind to a specific domain controller to serve as the // source of a replication connection DomainController targetDc = DomainController.GetDomainController(targetContext); // invoke the kcc to check the replication topology for the // target domain controller targetDc.CheckReplicationConsistency(); Console.WriteLine("\nReplication topology is consistent.\n"); // sync replica from all neighbors targetDc.TriggerSyncReplicaFromNeighbors(partitionName); Console.WriteLine("\nTriggered a synchronization of partition {0} " + "to {1} from all neighbors succeeded.", partitionName, targetServer); } catch (Exception e) { Console.WriteLine("\r\nUnexpected exception occured:\n{0}:{1}", e.GetType().Name, e.Message); } }
public async Task Domain_Moking_LookupClient() { //arrange var mock = new Mock <ILookupClient>(); var domainName = "test.com"; LookupClient lookupClient = new LookupClient(); var responseDns = new Mock <IDnsQueryResponse>(); mock.Setup(l => l.QueryAsync(domainName, QueryType.ANY)).Returns(Task.FromResult(responseDns.Object)); //arrange var options = new DbContextOptionsBuilder <DatabaseContext>() .UseInMemoryDatabase(databaseName: "Find_searches_url") .Options; // Use a clean instance of the context to run the test using (var db = new DatabaseContext(options)) { //inject lookupClient in controller constructor var controller = new DomainController(db, _lookupClient); //act var response = await controller.Get("test.com") as OkObjectResult; var obj = response.Value as DomainModel; Assert.IsNotNull(obj); } }
public void Domain_Not_In_Database() { //arrange var options = new DbContextOptionsBuilder <DatabaseContext>() .UseInMemoryDatabase(databaseName: "Find_searches_url") .Options; var domainName = "test.com"; var lookupClient = new Mock <ILookupClientWrapper>(); var dnsResponse = new Mock <IDnsQueryResponse>(); var whoisResponse = new Mock <WhoisResponse>(); var whoisClient = new Mock <WhoisClientWrapper>(); whoisClient.Setup(w => w.QueryAsync(domainName)).Returns(Task.FromResult(whoisResponse.Object)); lookupClient.Setup(l => l.QueryAsync(domainName, QueryType.ANY)).Returns(Task.FromResult(dnsResponse.Object)); // Use a clean instance of the context to run the test using (var db = new DatabaseContext(options)) { var controller = new DomainController(db, lookupClient.Object, whoisClient.Object); //act var response = controller.Get("test.com"); var result = response.Result as OkObjectResult; var obj = result.Value as Desafio.Umbler.Application.ViewModels.DomainViewModel; Assert.IsNotNull(obj); } }
public static void ReplicateFromSource(string sourceServer, string targetServer, string partitionName) { try { // set a directory server context for the target server DirectoryContext targetContext = new DirectoryContext( DirectoryContextType.DirectoryServer, targetServer); // bind to a specific dc to serve as the replication source DomainController targetDc = DomainController.GetDomainController(targetContext); // invoke the kcc to check the replication topology of the target dc targetDc.CheckReplicationConsistency(); Console.WriteLine("\nReplication topology is consistent.\n"); // trigger a synchornization of a replica from a source dc // to the target dc targetDc.SyncReplicaFromServer(partitionName, sourceServer); Console.WriteLine("\nSynchronize partition \"{0}\" " + "from server {1} to {2} succeed", partitionName, sourceServer, targetServer); } catch (Exception e) { Console.WriteLine("\r\nUnexpected exception occured:\n{0}:{1}", e.GetType().Name, e.Message); } }
//------------------------------------------------------------------------------------ /// <summary> /// Returns an Active Directory searcher for the Microsoft domain. /// </summary> //------------------------------------------------------------------------------------ private static DirectorySearcher GetCachedDirectorySearcher(string domainName) { s_searchers = null; if (s_searchers == null) { s_searchers = new Dictionary <string, DirectorySearcher>(); } if (!s_searchers.ContainsKey(domainName)) { Domain domain = Domain.GetDomain(new DirectoryContext(DirectoryContextType.Domain, domainName)); if (domain != null) { DomainController dc = domain.FindDomainController(); if (dc != null) { DirectorySearcher searcher = dc.GetDirectorySearcher(); s_searchers.Add(domainName, searcher); } } } if (!s_searchers.ContainsKey(domainName)) { return(null); } return(s_searchers[domainName]); }
public bool IsAdSchemaVersion15OrHigher() { string domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName; DirectoryContext context = new DirectoryContext(DirectoryContextType.Domain, domainName); DomainController domainController = DomainController.FindOne(context); IConfigurationSession configurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(domainController.Name, true, ConsistencyMode.FullyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 657, "IsAdSchemaVersion15OrHigher", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Deployment\\HybridConfigurationDetection\\HybridConfigurationDetection.cs"); ITopologyConfigurationSession topologyConfigurationSession = DirectorySessionFactory.Default.CreateTopologyConfigurationSession(ConsistencyMode.PartiallyConsistent, ADSessionSettings.FromRootOrgScopeSet(), 663, "IsAdSchemaVersion15OrHigher", "f:\\15.00.1497\\sources\\dev\\Management\\src\\Deployment\\HybridConfigurationDetection\\HybridConfigurationDetection.cs"); bool result; try { ADSchemaAttributeObject[] array = configurationSession.Find <ADSchemaAttributeObject>(topologyConfigurationSession.SchemaNamingContext, QueryScope.SubTree, new ComparisonFilter(ComparisonOperator.Equal, ADObjectSchema.Name, "ms-Exch-Schema-Version-Pt"), null, 1); if (array.Length != 0) { result = (array[0].RangeUpper >= 15137); } else { result = false; } } catch (Exception ex) { throw new HybridConfigurationDetectionException(new LocalizedString(ex.Message), ex); } return(result); }
private void loadSettings() { chkUnitActionLines.Checked = DomainController.Instance().getUnitActionLines(); chkToolTips.Checked = DomainController.Instance().getTooltips(); chkRepeat.Checked = DomainController.Instance().getMusicRepeat(); chkShuffle.Checked = DomainController.Instance().getMusicShuffle(); chkBackbuffer.Checked = DomainController.Instance().getBackbuffer(); chkIntro.Checked = DomainController.Instance().getIntro(); chkCD.Checked = DomainController.Instance().getCD(); chkProcAffinity.Checked = DomainController.Instance().getProcAffinity(); try { trbScoreVolume.Value = Convert.ToInt32(DomainController.Instance().getScoreVolume() * 20); trbVoiceVolume.Value = Convert.ToInt32(DomainController.Instance().getVoiceVolume() * 20); trbSoundVolume.Value = Convert.ToInt32(DomainController.Instance().getSoundVolume() * 20); trbDragDistance.Value = DomainController.Instance().getDragDistance(); } catch { } chkUseCustomColors.Checked = DomainController.Instance().getOverrideColors(); ColorOverrides = DomainController.Instance().getColorOverrides(); TextBackgroundColor = DomainController.Instance().getTextBackgroundColor(); chkUseOnlyRightClickDeselect.Checked = DomainController.Instance().getOnlyRightClickDeselect(); chkUseDisableAltTab.Checked = DomainController.Instance().getDisableAltTab(); chkUseDisableEdgeScrolling.Checked = DomainController.Instance().getDisableEdgeScrolling(); }
public void FindAll_NoSuchName_ReturnsEmpty() { var context = new DirectoryContext(DirectoryContextType.Domain, "\0"); Assert.Empty(DomainController.FindAll(context)); Assert.Empty(DomainController.FindAll(context, "siteName")); }
public void Domain_In_Database() { //arrange var options = new DbContextOptionsBuilder <DatabaseContext>() .UseInMemoryDatabase(databaseName: "Find_searches_url") .Options; var domain = new Domain { Id = 1, Ip = "192.168.0.1", Name = "test.com", UpdatedAt = DateTime.Now, HostedAt = "Bitium.corp", Ttl = 60, WhoIs = "Ns.Bitium.com" }; // Insert seed data into the database using one instance of the context using (var db = new DatabaseContext(options)) { db.Domains.Add(domain); db.SaveChanges(); } // Use a clean instance of the context to run the test using (var db = new DatabaseContext(options)) { var controller = new DomainController(db); //act var response = controller.Get("test.com"); var result = response.Result as OkObjectResult; var obj = result.Value as Domain; Assert.AreEqual(obj.Id, domain.Id); Assert.AreEqual(obj.Ip, domain.Ip); Assert.AreEqual(obj.Name, domain.Name); } }
public void FindOne_EmptySiteName_ThrowsArgumentException() { var context = new DirectoryContext(DirectoryContextType.Domain); AssertExtensions.Throws <ArgumentException>("siteName", () => DomainController.FindOne(context, string.Empty)); AssertExtensions.Throws <ArgumentException>("siteName", () => DomainController.FindOne(context, string.Empty, LocatorOptions.AvoidSelf)); }
public void FindOne_InvalidFlag_ThrowsArgumentException(LocatorOptions flag) { var context = new DirectoryContext(DirectoryContextType.Domain); AssertExtensions.Throws <ArgumentException>("flag", () => DomainController.FindOne(context, flag)); AssertExtensions.Throws <ArgumentException>("flag", () => DomainController.FindOne(context, "siteName", flag)); }
private void OnResetPasswordLoad(object o, EventArgs args) { DomainController domainController = DomainController.GetDomainController(); domains = domainController.GetLoggedInDomains(); if (domains == null) { this.Respond(ResponseType.DeleteEvent); return; } string defaultDomainID = simws.GetDefaultDomainID(); int defaultDomain = 0; for (int x = 0; x < domains.Length; x++) { domainComboBox.AppendText(domains[x].Name + "-" + domains[x].Host); if (defaultDomainID != null && defaultDomainID == domains[x].ID) { defaultDomain = x; } } if (domains.Length > 0) { domainComboBox.Active = defaultDomain; } oldPassword.Sensitive = newPassword.Sensitive = confirmPassword.Sensitive = savePassword.Sensitive = true; }
/// <summary> /// Display RA Name /// </summary> private void DisplayRAName() { string domainID = this.Domain; DomainController domController = DomainController.GetDomainController(); string raName = domController.GetRAName(domainID); email.Text = Util.GS("Information Not Available"); if (raName == null || raName == "") { recoveryAgentCombo.Text = Util.GS("Information Not Available"); } else { //parsing the RAName by '=' char [] EmailParser = { '=' }; string [] ParsedString = raName.Split(EmailParser); string emailID = ""; if (ParsedString.Length > 1) { for (int x = 0; x < ParsedString.Length; x++) { // Iterate through the parsed string to again parse for '@' to get mail-id char [] FinalEmailParser = { '@' }; string [] FinalParsedString = ParsedString[x].Split(FinalEmailParser); if (FinalParsedString.Length > 1) { emailID = ParsedString[x]; email.Text = emailID; } } } //Console.WriteLine("email ID :"+emailID); recoveryAgentCombo.Text = raName; } }
private DirectoryEntry GetADRoot() { DirectoryEntry entryRoot; try { if (DomainController != null && DomainController.Trim().Length > 0) { entryRoot = new DirectoryEntry(string.Format("LDAP://{0}:389/RootDSE", DomainController)); string domain = entryRoot.Properties["defaultNamingContext"][0].ToString(); entryRoot = new DirectoryEntry("LDAP://" + domain); } else { entryRoot = new DirectoryEntry("LDAP://RootDSE"); string domain = entryRoot.Properties["defaultNamingContext"][0].ToString(); entryRoot = new DirectoryEntry("LDAP://" + domain); } } catch (Exception ex) { throw new Exception(string.Format("Error trying to get AD domain root '{0}'", DomainController), ex); } return(entryRoot); }
public void Domain_Moking_LookupClient() { //arrange var lookupClient = new Mock <LookupClient>(); var domainName = "test.com"; var dnsResponse = new Mock <IDnsQueryResponse>(); lookupClient.Setup(l => l.QueryAsync(domainName, QueryType.ANY)).Returns(Task.FromResult(dnsResponse.Object)); //arrange var options = new DbContextOptionsBuilder <DatabaseContext>() .UseInMemoryDatabase(databaseName: "Find_searches_url") .Options; // Use a clean instance of the context to run the test using (var db = new DatabaseContext(options)) { //inject lookupClient in controller constructor var controller = new DomainController(db /*,IWhoisClient, ILookupClient*/); //act var response = controller.Get("test.com"); var result = response.Result as OkObjectResult; var obj = result.Value as Domain; Assert.IsNotNull(obj); } }
public void GetDirectoryServers() { DomainController dc = null; AdamInstance adam = null; //create a new DirectoryContext for a //domain controller using a name and //default credentials DirectoryContext dcContext = new DirectoryContext( DirectoryContextType.DirectoryServer, "mydc.mydomain.com"); //update using (dc = DomainController.GetDomainController(dcContext)) { Console.WriteLine(dc.Name); } //Now, connect to a local ADAM instance //specifying a port and local admin credentials DirectoryContext adamContext = new DirectoryContext( DirectoryContextType.DirectoryServer, "127.0.0.1:50000", //update @"MYMACHINE\administrator", "MySecret!0"); using (adam = AdamInstance.GetAdamInstance(adamContext)) { Console.WriteLine(adam.Name); } //OUT: //mydc.mydomain.com //myadaminstance.mydomain.com }
private void _btnInitialize_Click(object sender, EventArgs e) { var controller = new DomainController(); var result = controller.CreateTable(); if (result.Error) { LogTest(result.Message); } var subdomaincontroller = new SubdomainController(); var subdomainresult = subdomaincontroller.CreateTable(); if (subdomainresult.Error) { LogTest(result.Message); } var ignorecontroller = new DomainIgnoreController(); var ignoreresult = ignorecontroller.CreateTable(); if (subdomainresult.Error) { LogTest(result.Message); } LogTest("Tables Created!"); }
public void FindOne_NullContext_ThrowsArgumentNullException() { AssertExtensions.Throws <ArgumentNullException>("context", () => DomainController.FindOne(null)); AssertExtensions.Throws <ArgumentNullException>("context", () => DomainController.FindOne(null, "siteName")); AssertExtensions.Throws <ArgumentNullException>("context", () => DomainController.FindOne(null, LocatorOptions.AvoidSelf)); AssertExtensions.Throws <ArgumentNullException>("context", () => DomainController.FindOne(null, "siteName", LocatorOptions.AvoidSelf)); }
public DomainControllerViewModel(DomainController domainController) { Domain = domainController.Domain; LDAP = domainController.LDAP; Username = domainController.Username; Password = domainController.Password; }
internal static DomainController GetDomainController(ActiveDirectoryConfiguration configuration) { String serverName = configuration.LDAPHostName; DomainController controller = null; if ((serverName == null) || (serverName.Length == 0)) { // get the active directory schema DirectoryContext context = new DirectoryContext( DirectoryContextType.Domain, configuration.DomainName, configuration.DirectoryAdminName, configuration.DirectoryAdminPassword); controller = DomainController.FindOne(context); } else { DirectoryContext context = new DirectoryContext( DirectoryContextType.DirectoryServer, configuration.LDAPHostName, configuration.DirectoryAdminName, configuration.DirectoryAdminPassword); controller = DomainController.GetDomainController(context); } return(controller); }
/// <summary> /// Event Handler for Reset Passphrase Load /// </summary> private void OnResetPassphraseLoad(object o, EventArgs args) { DomainController domainController = DomainController.GetDomainController(); domains = domainController.GetLoggedInDomains(); if (domains == null) { this.Respond(ResponseType.DeleteEvent); return; } string defaultDomainID = simws.GetDefaultDomainID(); int defaultDomain = 0; for (int x = 0; x < domains.Length; x++) { domainComboBox.AppendText(domains[x].Name + "-" + domains[x].Host); if (defaultDomainID != null && defaultDomainID == domains[x].ID) { defaultDomain = x; } } if (domains.Length > 0) { domainComboBox.Active = defaultDomain; } DisplayRAList(); UpdateUI(); }
public void TestFindCurrentDomainController() { using (DomainController domainController = DomainController.GetCurrent()) { Assert.IsNotNull(domainController); } }
static DomainManager() { RootSubPath = ""; try { ComputerName = Environment.MachineName; System.DirectoryServices.ActiveDirectory.Domain domain; try { domain = System.DirectoryServices.ActiveDirectory.Domain.GetCurrentDomain(); } catch (Exception) { domain = System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain(); } DomainName = domain.Name; DomainController domainController = domain.PdcRoleOwner; DomainControllerName = domainController.Name.Split('.')[0]; domain.Dispose(); domainController.Dispose(); } catch (Exception) { DomainName = ComputerName; DomainControllerName = ""; } }
protected override void ProcessRecord() { if (IsForestScope) { using (Forest forest = AD.Forest.GetForest(CurrentDirectoryContext)) { foreach (Domain domain in forest.Domains) { using (domain) { WriteObject(domain.DomainControllers, true); } } } } else if (IsDomainScope) { WriteObject(DomainController.FindAll(CurrentDirectoryContext), true); } else if (IsSiteScope) { if (string.IsNullOrEmpty(Name)) { Name = MachineSiteName; } WriteObject(DomainController.FindAll(CurrentDirectoryContext, Name), true); } else { WriteObject(DomainController.GetDomainController(CurrentDirectoryContext)); } }
public void FindOne_InvalidName_ThrowsException(string name, Type exceptionType) { var context = new DirectoryContext(DirectoryContextType.Domain, name); Assert.Throws(exceptionType, () => DomainController.FindOne(context, "siteName")); Assert.Throws(exceptionType, () => DomainController.FindOne(context, "siteName", LocatorOptions.AvoidSelf)); }
public DomainManager() { Domain domain = null; DomainController domainController = null; try { domain = Domain.GetCurrentDomain(); DomainName = domain.Name; domainController = domain.PdcRoleOwner; DomainControllerName = domainController.Name.Split('.')[0]; ComputerName = Environment.MachineName; } finally { if (domain != null) { domain.Dispose(); } if (domainController != null) { domainController.Dispose(); } } }
static void Main(string[] args) { SimpleLoadingOfConfiguration slc = new SimpleLoadingOfConfiguration(); LoadingOfConfigurationByAllowingAppToDetermineConfigPath lcadc = new LoadingOfConfigurationByAllowingAppToDetermineConfigPath(); LoadingByProvidingSectionNameOnly lpso = new LoadingByProvidingSectionNameOnly(); LoadingMultipleConfigSections lmc = new LoadingMultipleConfigSections(); UsingInnerCollections uic = new UsingInnerCollections(); LoadingAConfigFileThatIsNotTheDefaultConfig lcf = new LoadingAConfigFileThatIsNotTheDefaultConfig(); CreatingStronglyTypedObjectsFromConfig cstofc = new CreatingStronglyTypedObjectsFromConfig(); //wrapping configuration MoreComplexExamples.WrappingConfigurationIntoALoader.DomainController wdc = new MoreComplexExamples.WrappingConfigurationIntoALoader.DomainController(); //auto generate object from config file. MoreComplexExamples.AutoGenerateModelsFromConfig.DomainController autoGen = new MoreComplexExamples.AutoGenerateModelsFromConfig.DomainController(); //auto generate object from config file, with mapping values. MoreComplexExamples.MappingFieldsAutoGen.DomainController mappingGen = new MoreComplexExamples.MappingFieldsAutoGen.DomainController(); MoreComplexExamples.AutoGenerateModelsFromConfigWithDefaultValues.DomainController autoGenWithDefaults = new MoreComplexExamples.AutoGenerateModelsFromConfigWithDefaultValues.DomainController(); MoreComplexExamples.AutoGenWithNonEmptyConstructor.DomainController autoGenWithNonEmptyCtor = new MoreComplexExamples.AutoGenWithNonEmptyConstructor.DomainController(); MoreComplexExamples.ValueInheritance.DomainController inHeritanceExample = new DomainController(); Console.WriteLine("all examples run, press any key to exit"); Console.ReadKey(); }
public void FindAll_InvalidContextType_ThrowsArgumentException(DirectoryContextType contextType) { var context = new DirectoryContext(contextType, "name"); AssertExtensions.Throws <ArgumentException>("context", () => DomainController.FindAll(context)); AssertExtensions.Throws <ArgumentException>("context", () => DomainController.FindAll(context, "siteName")); }
static void Main() { //Clipboard.SetText(Utilities.calculateMD5ForFile("dxwnd.dll")); return; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); DomainController.Instance(); Application.Run(new SetupFrame()); }
/** * Retrieves the current highest Update Sequence Number that has been committed up to this point in the database of Active * Directory. * * @return The current highest committed Update Sequence Number. */ protected long RetrieveRemoteHighestCommittedUsn() { DirectoryContext context = new DirectoryContext(DirectoryContextType.DirectoryServer, _ldapConfig.GetUrl(), _ldapConfig.GetBindUser(), _ldapConfig.GetBindPassword()); using (DomainController domainController = DomainController.GetDomainController(context)) return(domainController.HighestCommittedUsn); }
// Use this for initialization void Start() { domainController = DomainController.getInstance(); controlObject = GameObject.Find("ControllerObject"); controlScript = (ControllerObjectScript)controlObject.GetComponent("ControllerObjectScript"); controlScript.SetPlayerObject(this.gameObject); cam.parent = transform; cursorLocked = false; }
// Methods public bool Contains(DomainController domainController) {}
public void CopyTo(DomainController[] domainControllers, int index) {}
public int IndexOf(DomainController domainController) {}
// Use this for initialization void Start() { domainController = DomainController.getInstance(); }