public void RaiseDomainFunctionality(System.DirectoryServices.ActiveDirectory.DomainMode domainMode) { base.CheckIfDisposed(); if ((domainMode < System.DirectoryServices.ActiveDirectory.DomainMode.Windows2000MixedDomain) || (domainMode > System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008R2Domain)) { throw new InvalidEnumArgumentException("domainMode", (int) domainMode, typeof(System.DirectoryServices.ActiveDirectory.DomainMode)); } System.DirectoryServices.ActiveDirectory.DomainMode mode = this.GetDomainMode(); DirectoryEntry directoryEntry = null; try { directoryEntry = DirectoryEntryManager.GetDirectoryEntry(base.context, base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext)); switch (mode) { case System.DirectoryServices.ActiveDirectory.DomainMode.Windows2000MixedDomain: if (domainMode != System.DirectoryServices.ActiveDirectory.DomainMode.Windows2000NativeDomain) { break; } directoryEntry.Properties[PropertyManager.NTMixedDomain].Value = 0; goto Label_0286; case System.DirectoryServices.ActiveDirectory.DomainMode.Windows2000NativeDomain: if (domainMode != System.DirectoryServices.ActiveDirectory.DomainMode.Windows2003Domain) { goto Label_012A; } directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 2; goto Label_0286; case System.DirectoryServices.ActiveDirectory.DomainMode.Windows2003InterimDomain: if (domainMode != System.DirectoryServices.ActiveDirectory.DomainMode.Windows2003Domain) { throw new ArgumentException(Res.GetString("InvalidMode"), "domainMode"); } directoryEntry.Properties[PropertyManager.NTMixedDomain].Value = 0; directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 2; goto Label_0286; case System.DirectoryServices.ActiveDirectory.DomainMode.Windows2003Domain: if (domainMode != System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008Domain) { goto Label_01FF; } directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 3; goto Label_0286; case System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008Domain: if (domainMode != System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008R2Domain) { throw new ArgumentException(Res.GetString("InvalidMode"), "domainMode"); } directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 4; goto Label_0286; case System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008R2Domain: throw new ArgumentException(Res.GetString("InvalidMode"), "domainMode"); default: throw new ActiveDirectoryOperationException(); } if (domainMode == System.DirectoryServices.ActiveDirectory.DomainMode.Windows2003InterimDomain) { directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 1; goto Label_0286; } if (domainMode == System.DirectoryServices.ActiveDirectory.DomainMode.Windows2003Domain) { directoryEntry.Properties[PropertyManager.NTMixedDomain].Value = 0; directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 2; goto Label_0286; } throw new ArgumentException(Res.GetString("InvalidMode"), "domainMode"); Label_012A: if (domainMode == System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008Domain) { directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 3; goto Label_0286; } if (domainMode == System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008R2Domain) { directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 4; goto Label_0286; } throw new ArgumentException(Res.GetString("InvalidMode"), "domainMode"); Label_01FF: if (domainMode == System.DirectoryServices.ActiveDirectory.DomainMode.Windows2008R2Domain) { directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = 4; } else { throw new ArgumentException(Res.GetString("InvalidMode"), "domainMode"); } Label_0286: directoryEntry.CommitChanges(); } catch (COMException exception) { if (exception.ErrorCode == -2147016694) { throw new ArgumentException(Res.GetString("NoW2K3DCs"), "domainMode"); } throw ExceptionHelper.GetExceptionFromCOMException(base.context, exception); } finally { if (directoryEntry != null) { directoryEntry.Dispose(); } } this.currentDomainMode = ~System.DirectoryServices.ActiveDirectory.DomainMode.Windows2000MixedDomain; }
internal Domain(DirectoryContext context, string domainName, DirectoryEntryManager directoryEntryMgr) : base(context, domainName) { this.currentDomainMode = ~System.DirectoryServices.ActiveDirectory.DomainMode.Windows2000MixedDomain; base.directoryEntryMgr = directoryEntryMgr; }