public void RaiseForestFunctionality(System.DirectoryServices.ActiveDirectory.ForestMode forestMode)
        {
            this.CheckIfDisposed();
            if ((forestMode < System.DirectoryServices.ActiveDirectory.ForestMode.Windows2000Forest) || (forestMode > System.DirectoryServices.ActiveDirectory.ForestMode.Windows2008R2Forest))
            {
                throw new InvalidEnumArgumentException("forestMode", (int)forestMode, typeof(System.DirectoryServices.ActiveDirectory.ForestMode));
            }
            if (forestMode <= this.GetForestMode())
            {
                throw new ArgumentException(Res.GetString("InvalidMode"), "forestMode");
            }
            DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer));

            try
            {
                directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = (int)forestMode;
                directoryEntry.CommitChanges();
            }
            catch (COMException exception)
            {
                if (exception.ErrorCode == -2147016694)
                {
                    throw new ArgumentException(Res.GetString("NoW2K3DCsInForest"), "forestMode");
                }
                throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception);
            }
            finally
            {
                directoryEntry.Dispose();
            }
            this.currentForestMode = ~System.DirectoryServices.ActiveDirectory.ForestMode.Windows2000Forest;
        }
 internal Forest(DirectoryContext context, string forestDnsName, DirectoryEntryManager directoryEntryMgr)
 {
     this.dsHandle = IntPtr.Zero;
     this.authIdentity = IntPtr.Zero;
     this.currentForestMode = ~System.DirectoryServices.ActiveDirectory.ForestMode.Windows2000Forest;
     this.context = context;
     this.directoryEntryMgr = directoryEntryMgr;
     this.forestDnsName = forestDnsName;
 }
 internal Forest(DirectoryContext context, string forestDnsName, DirectoryEntryManager directoryEntryMgr)
 {
     this.dsHandle          = IntPtr.Zero;
     this.authIdentity      = IntPtr.Zero;
     this.currentForestMode = ~System.DirectoryServices.ActiveDirectory.ForestMode.Windows2000Forest;
     this.context           = context;
     this.directoryEntryMgr = directoryEntryMgr;
     this.forestDnsName     = forestDnsName;
 }
 public void RaiseForestFunctionality(System.DirectoryServices.ActiveDirectory.ForestMode forestMode)
 {
     this.CheckIfDisposed();
     if ((forestMode < System.DirectoryServices.ActiveDirectory.ForestMode.Windows2000Forest) || (forestMode > System.DirectoryServices.ActiveDirectory.ForestMode.Windows2008R2Forest))
     {
         throw new InvalidEnumArgumentException("forestMode", (int) forestMode, typeof(System.DirectoryServices.ActiveDirectory.ForestMode));
     }
     if (forestMode <= this.GetForestMode())
     {
         throw new ArgumentException(Res.GetString("InvalidMode"), "forestMode");
     }
     DirectoryEntry directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer));
     try
     {
         directoryEntry.Properties[PropertyManager.MsDSBehaviorVersion].Value = (int) forestMode;
         directoryEntry.CommitChanges();
     }
     catch (COMException exception)
     {
         if (exception.ErrorCode == -2147016694)
         {
             throw new ArgumentException(Res.GetString("NoW2K3DCsInForest"), "forestMode");
         }
         throw ExceptionHelper.GetExceptionFromCOMException(this.context, exception);
     }
     finally
     {
         directoryEntry.Dispose();
     }
     this.currentForestMode = ~System.DirectoryServices.ActiveDirectory.ForestMode.Windows2000Forest;
 }