internal ADDirectoryEntry(ADDomain Domain, ADDomainController DomainController, DirectoryEntry Entry) { if (Domain == null) throw new ArgumentNullException("Domain"); if (DomainController == null) throw new ArgumentNullException("DomainController"); if (Entry == null) throw new ArgumentNullException("Entry"); this.Domain = Domain; this.DomainController = DomainController; this.Entry = Entry; }
private ADDomainController DiscoverAvailableDomainController(bool RequireWritable) { LocatorOptions locatorOptions; if (RequireWritable) locatorOptions = LocatorOptions.ForceRediscovery | LocatorOptions.WriteableRequired; else locatorOptions = LocatorOptions.ForceRediscovery; var dc = this.Domain.FindDomainController(locatorOptions); var dcName = dc.Name; var existingDC = this.DomainControllers.FirstOrDefault(edc => edc.Name == dcName); if (existingDC != null) { // DC already in scope // Native API indicates writable if (RequireWritable) existingDC.IsWritable = true; // Native API indicates it is available existingDC.IsAvailable = true; return existingDC; } else { // New DC discovered var adDC = new ADDomainController(this.context, dc, this, dc.SiteName == this.context.Site.Name, RequireWritable); // Add DC to Available Servers this.domainControllers.Push(adDC); return adDC; } }