public void SeizeRoleOwnership(AdamRole role) { // set the "fsmoRoleOwner" attribute on the appropriate role object // to the NTDSAObjectName of this ADAM Instance string roleObjectDN = null; CheckIfDisposed(); switch (role) { case AdamRole.SchemaRole: { roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext); break; } case AdamRole.NamingRole: { roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer); break; } default: { throw new InvalidEnumArgumentException(nameof(role), (int)role, typeof(AdamRole)); } } DirectoryEntry roleObjectEntry = null; try { roleObjectEntry = DirectoryEntryManager.GetDirectoryEntry(context, roleObjectDN); 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; }
public void TransferRoleOwnership(AdamRole role) { base.CheckIfDisposed(); if ((role < AdamRole.SchemaRole) || (role > AdamRole.NamingRole)) { throw new InvalidEnumArgumentException("role", (int)role, typeof(AdamRole)); } 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; }
public void SeizeRoleOwnership(AdamRole role) { string dn = null; base.CheckIfDisposed(); switch (role) { case AdamRole.SchemaRole: dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext); break; case AdamRole.NamingRole: dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer); break; default: throw new InvalidEnumArgumentException("role", (int)role, typeof(AdamRole)); } 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; }
public void SeizeRoleOwnership(AdamRole role) { string str = null; base.CheckIfDisposed(); AdamRole adamRole = role; if (adamRole == AdamRole.SchemaRole) { str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext); } else if (adamRole == AdamRole.NamingRole) { str = this.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer); } else { throw new InvalidEnumArgumentException("role", (int)role, typeof(AdamRole)); } 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; }
public void TransferRoleOwnership(AdamRole role) { CheckIfDisposed(); if (role < AdamRole.SchemaRole || role > AdamRole.NamingRole) { throw new InvalidEnumArgumentException(nameof(role), (int)role, typeof(AdamRole)); } // set the appropriate attribute on the root dse try { 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; }
public void TransferRoleOwnership(AdamRole role) { base.CheckIfDisposed(); if (role < AdamRole.SchemaRole || role > AdamRole.NamingRole) { throw new InvalidEnumArgumentException("role", (int)role, typeof(AdamRole)); } 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; } }
public void TransferRoleOwnership(AdamRole role) { base.CheckIfDisposed(); if ((role < AdamRole.SchemaRole) || (role > AdamRole.NamingRole)) { throw new InvalidEnumArgumentException("role", (int) role, typeof(AdamRole)); } 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; }
public void SeizeRoleOwnership(AdamRole role) { string dn = null; base.CheckIfDisposed(); switch (role) { case AdamRole.SchemaRole: dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext); break; case AdamRole.NamingRole: dn = base.directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer); break; default: throw new InvalidEnumArgumentException("role", (int) role, typeof(AdamRole)); } 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; }
public void SeizeRoleOwnership(AdamRole role) { // set the "fsmoRoleOwner" attribute on the appropriate role object // to the NTDSAObjectName of this ADAM Instance string roleObjectDN = null; CheckIfDisposed(); switch (role) { case AdamRole.SchemaRole: { roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.SchemaNamingContext); break; } case AdamRole.NamingRole: { roleObjectDN = directoryEntryMgr.ExpandWellKnownDN(WellKnownDN.PartitionsContainer); break; } default: { throw new InvalidEnumArgumentException("role", (int)role, typeof(AdamRole)); } } DirectoryEntry roleObjectEntry = null; try { roleObjectEntry = DirectoryEntryManager.GetDirectoryEntry(context, roleObjectDN); 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; }
public void TransferRoleOwnership(AdamRole role) { CheckIfDisposed(); if (role < AdamRole.SchemaRole || role > AdamRole.NamingRole) { throw new InvalidEnumArgumentException("role", (int)role, typeof(AdamRole)); } // set the appropriate attribute on the root dse try { 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; }