コード例 #1
0
        public void SeizeRoleOwnership(ActiveDirectoryRole role)
        {
            string dn = null;

            base.CheckIfDisposed();
            switch (role)
            {
            case ActiveDirectoryRole.SchemaRole:
                dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext);
                break;

            case ActiveDirectoryRole.NamingRole:
                dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer);
                break;

            case ActiveDirectoryRole.PdcRole:
                dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext);
                break;

            case ActiveDirectoryRole.RidRole:
                dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.RidManager);
                break;

            case ActiveDirectoryRole.InfrastructureRole:
                dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.Infrastructure);
                break;

            default:
                throw new InvalidEnumArgumentException("role", (int)role, typeof(ActiveDirectoryRole));
            }
            DirectoryEntry directoryEntry = null;

            try
            {
                directoryEntry = DirectoryEntryManager.GetDirectoryEntry(base.context, dn);
                directoryEntry.Properties[PropertyManager.FsmoRoleOwner].Value = this.NtdsaObjectName;
                directoryEntry.CommitChanges();
            }
            catch (COMException exception)
            {
                throw System.DirectoryServices.ActiveDirectory.ExceptionHelper.GetExceptionFromCOMException(base.context, exception);
            }
            finally
            {
                if (directoryEntry != null)
                {
                    directoryEntry.Dispose();
                }
            }
            this.cachedRoles = null;
        }
コード例 #2
0
 public void TransferRoleOwnership(ActiveDirectoryRole role)
 {
     base.CheckIfDisposed();
     if ((role < ActiveDirectoryRole.SchemaRole) || (role > ActiveDirectoryRole.InfrastructureRole))
     {
         throw new InvalidEnumArgumentException("role", (int)role, typeof(ActiveDirectoryRole));
     }
     try
     {
         DirectoryEntry cachedDirectoryEntry = base.directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
         cachedDirectoryEntry.Properties[this.becomeRoleOwnerAttrs[(int)role]].Value = 1;
         cachedDirectoryEntry.CommitChanges();
     }
     catch (COMException exception)
     {
         throw System.DirectoryServices.ActiveDirectory.ExceptionHelper.GetExceptionFromCOMException(base.context, exception);
     }
     this.cachedRoles = null;
 }
コード例 #3
0
ファイル: DomainController.cs プロジェクト: chcosta/corefx
        public void SeizeRoleOwnership(ActiveDirectoryRole role)
        {
            // set the "fsmoRoleOwner" attribute on the appropriate role object
            // to the NTDSAObjectName of this DC
            string roleObjectDN = null;

            CheckIfDisposed();

            switch (role)
            {
                case ActiveDirectoryRole.SchemaRole:
                    {
                        roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext);
                        break;
                    }
                case ActiveDirectoryRole.NamingRole:
                    {
                        roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer);
                        break;
                    }
                case ActiveDirectoryRole.PdcRole:
                    {
                        roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext);
                        break;
                    }
                case ActiveDirectoryRole.RidRole:
                    {
                        roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.RidManager);
                        break;
                    }
                case ActiveDirectoryRole.InfrastructureRole:
                    {
                        roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.Infrastructure);
                        break;
                    }
                default:
                    throw new InvalidEnumArgumentException("role", (int)role, typeof(ActiveDirectoryRole));
            }

            DirectoryEntry roleObjectEntry = null;
            try
            {
                roleObjectEntry = DirectoryEntryManager.GetDirectoryEntry(context, roleObjectDN);

                // For RID FSMO role
                // Increment the RIDAvailablePool by 30k.
                if (role == ActiveDirectoryRole.RidRole)
                {
                    System.DirectoryServices.Interop.UnsafeNativeMethods.IADsLargeInteger ridPool = (System.DirectoryServices.Interop.UnsafeNativeMethods.IADsLargeInteger)roleObjectEntry.Properties[PropertyManager.RIDAvailablePool].Value;

                    // check the overflow of the low part
                    if (ridPool.LowPart + UpdateRidPoolSeizureValue < ridPool.LowPart)
                    {
                        throw new InvalidOperationException(Res.GetString(Res.UpdateAvailableRIDPoolOverflowFailure));
                    }
                    ridPool.LowPart += UpdateRidPoolSeizureValue;
                    roleObjectEntry.Properties[PropertyManager.RIDAvailablePool].Value = ridPool;
                }
                roleObjectEntry.Properties[PropertyManager.FsmoRoleOwner].Value = NtdsaObjectName;
                roleObjectEntry.CommitChanges();
            }
            catch (COMException e)
            {
                throw ExceptionHelper.GetExceptionFromCOMException(context, e);
            }
            finally
            {
                if (roleObjectEntry != null)
                {
                    roleObjectEntry.Dispose();
                }
            }

            // invalidate the role collection so that it gets loaded again next time
            _cachedRoles = null;
        }
コード例 #4
0
ファイル: DomainController.cs プロジェクト: chcosta/corefx
        public void TransferRoleOwnership(ActiveDirectoryRole role)
        {
            CheckIfDisposed();

            if (role < ActiveDirectoryRole.SchemaRole || role > ActiveDirectoryRole.InfrastructureRole)
            {
                throw new InvalidEnumArgumentException("role", (int)role, typeof(ActiveDirectoryRole));
            }

            try
            {
                // set the appropriate attribute on the rootDSE 
                DirectoryEntry rootDSE = directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
                rootDSE.Properties[_becomeRoleOwnerAttrs[(int)role]].Value = 1;
                rootDSE.CommitChanges();
            }
            catch (COMException e)
            {
                throw ExceptionHelper.GetExceptionFromCOMException(context, e); ;
            }

            // invalidate the role collection so that it gets loaded again next time
            _cachedRoles = null;
        }
コード例 #5
0
ファイル: DomainController.cs プロジェクト: nickchal/pash
		public void TransferRoleOwnership(ActiveDirectoryRole role)
		{
			base.CheckIfDisposed();
			if (role < ActiveDirectoryRole.SchemaRole || role > ActiveDirectoryRole.InfrastructureRole)
			{
				throw new InvalidEnumArgumentException("role", (int)role, typeof(ActiveDirectoryRole));
			}
			else
			{
				try
				{
					DirectoryEntry cachedDirectoryEntry = this.directoryEntryMgr.GetCachedDirectoryEntry(WellKnownDN.RootDSE);
					cachedDirectoryEntry.Properties[this.becomeRoleOwnerAttrs[(int)role]].Value = 1;
					cachedDirectoryEntry.CommitChanges();
				}
				catch (COMException cOMException1)
				{
					COMException cOMException = cOMException1;
					throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException);
				}
				this.cachedRoles = null;
				return;
			}
		}
コード例 #6
0
ファイル: DomainController.cs プロジェクト: nickchal/pash
		public void SeizeRoleOwnership(ActiveDirectoryRole role)
		{
			string str = null;
			base.CheckIfDisposed();
			ActiveDirectoryRole activeDirectoryRole = role;
			if (activeDirectoryRole == ActiveDirectoryRole.SchemaRole)
			{
				str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext);
			}
			else if (activeDirectoryRole == ActiveDirectoryRole.NamingRole)
			{
				str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer);
			}
			else if (activeDirectoryRole == ActiveDirectoryRole.PdcRole)
			{
				str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.DefaultNamingContext);
			}
			else if (activeDirectoryRole == ActiveDirectoryRole.RidRole)
			{
				str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.RidManager);
			}
			else if (activeDirectoryRole == ActiveDirectoryRole.InfrastructureRole)
			{
				str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.Infrastructure);
			}
			else
			{
				throw new InvalidEnumArgumentException("role", (int)role, typeof(ActiveDirectoryRole));
			}
			DirectoryEntry directoryEntry = null;
			using (directoryEntry)
			{
				try
				{
					directoryEntry = DirectoryEntryManager.GetDirectoryEntry(this.context, str);
					directoryEntry.Properties[PropertyManager.FsmoRoleOwner].Value = this.NtdsaObjectName;
					directoryEntry.CommitChanges();
				}
				catch (COMException cOMException1)
				{
					COMException cOMException = cOMException1;
					throw ExceptionHelper.GetExceptionFromCOMException(this.context, cOMException);
				}
			}
			this.cachedRoles = null;
		}