public static string GetFSMORoleCN(DsDomain dsdomain, FSMORoles fsmoRole) { string dn = null; if (dsdomain is AddsDomain) { string defaultNC = LdapUtility.ConvertUshortArrayToString( ((AddsDomain)dsdomain).DomainNC.StringName); switch (fsmoRole) { case FSMORoles.PDC: { dn = defaultNC; break; } case FSMORoles.RidAllocation: { dn = "CN=RID Manager$,CN=System," + defaultNC; break; } case FSMORoles.Infrastructure: { dn = "CN=Infrastructure," + defaultNC; break; } default: break; } } else { switch (fsmoRole) { case FSMORoles.Schema: { dn = LdapUtility.ConvertUshortArrayToString( dsdomain.SchemaNC.StringName); break; } case FSMORoles.DomainNaming: { dn = "CN=Partitions," + LdapUtility.ConvertUshortArrayToString( dsdomain.ConfigNC.StringName); break; } default: break; } } return(dn); }
/// <summary> /// get the DSName of the specified NC. /// </summary> /// <param name="domain">Domain that contains the NC.</param> /// <param name="ncType">The naming context type.</param> /// <returns>The DSName of the specified NC. Null if the NC is not existed.</returns> public static DSNAME GetNamingContextDSName(DsDomain domain, NamingContext ncType) { DSNAME ncDsName = new DSNAME(); if (ncType == NamingContext.ConfigNC) { ncDsName = domain.ConfigNC; } else if (ncType == NamingContext.SchemaNC) { ncDsName = domain.SchemaNC; } else if (ncType == NamingContext.DomainNC) { if (domain is AddsDomain) { ncDsName = ((AddsDomain)domain).DomainNC; } } else { if (domain is AdldsDomain) { ncDsName = ((AdldsDomain)domain).AppNCs[0]; } } return(ncDsName); }
/// <summary> /// init objects for DomainStore /// </summary> static void InitDomainObjects() { #region domain objects DsDomain primaryDomain = ldapAd.GetDomainInfo( ADCommonServerAdapter.Instance(testSite).PDCNetbiosName + "." + ADCommonServerAdapter.Instance(testSite).PrimaryDomainDnsName + (testDS == true ? "" : ":" + testSite.Properties[Machine.WritableDC1.ToString() + ".LDSPort"]), UserStore[User.ParentDomainAdmin] ); DomainStore.Add(DomainEnum.PrimaryDomain, primaryDomain); UserStore[User.ParentDomainAdmin].Domain = primaryDomain; //Should initialize child domain and trust domain object here if (testDS) { DsDomain InvalidDomain = new AddsDomain(); InvalidDomain.FsmoRoleOwners = new Dictionary <FSMORoles, string>(); InvalidDomain.DNSName = testSite.Properties[DomainEnum.InvalidDomain.ToString() + ".DS.DNSName"]; DomainStore.Add(DomainEnum.InvalidDomain, InvalidDomain); } else { DsDomain InvalidDomain = new AdldsDomain(); InvalidDomain.FsmoRoleOwners = new Dictionary <FSMORoles, string>(); InvalidDomain.DNSName = testSite.Properties[DomainEnum.InvalidDomain.ToString() + ".LDS.DNSName"]; DomainStore.Add(DomainEnum.InvalidDomain, InvalidDomain); } #endregion }
/// <summary> /// get the DN of the specified NC. /// </summary> /// <param name="domain">Domain that contains the NC.</param> /// <param name="ncType">The naming context type.</param> /// <returns>The DN of the specified NC. Null if the NC is not existed.</returns> public static string GetNamingContextDN(DsDomain domain, NamingContext ncType) { DSNAME ncDsName; if (ncType == NamingContext.ConfigNC) { ncDsName = domain.ConfigNC; } else if (ncType == NamingContext.SchemaNC) { ncDsName = domain.SchemaNC; } else if (ncType == NamingContext.DomainNC) { if (domain is AddsDomain) { ncDsName = ((AddsDomain)domain).DomainNC; } else { return(null); } } else { if (domain is AdldsDomain) { ncDsName = ((AdldsDomain)domain).AppNCs[0]; } else { return(null); } } return(LdapUtility.ConvertUshortArrayToString(ncDsName.StringName)); }
void VerifyCrackNamesListRoles( DsServer dc, DRS_MSG_CRACKREQ req, DRS_MSG_CRACKREPLY?reply) { bool isLds = (dc is AdldsServer); DsDomain domain = dc.Domain; DS_NAME_RESULTW result = reply.Value.V1.pResult[0]; if (isLds) { testSite.Assert.IsTrue( result.cItems == 2, "IDL_DRSCrackNames: DS_LIST_ROLES: FSMO role owner of a LDS server should be 2." ); } else { testSite.Assert.IsTrue( result.cItems == 5, "IDL_DRSCrackNames: DS_LIST_ROLES: FSMO role owner of a DS server should be 5." ); } for (int i = 0; i < result.cItems; ++i) { testSite.Assert.IsTrue( result.rItems[i].status == DS_NAME_ERROR.DS_NAME_NO_ERROR, "IDL_DRSCrackNames: DS_LIST_ROLES: return status should be 0, got {0}", result.rItems[i].status ); } testSite.Assert.IsTrue( domain.FsmoRoleOwners[FSMORoles.Schema] == result.rItems[0].pName, "IDL_DRSCrackNames: DS_LIST_ROLES: failed to verify schema owner." ); testSite.Assert.IsTrue( domain.FsmoRoleOwners[FSMORoles.DomainNaming] == result.rItems[0].pName, "IDL_DRSCrackNames: DS_LIST_ROLES: failed to verify domain naming owner." ); // DS server might have 3 more roles. if (!isLds) { testSite.Assert.IsTrue( domain.FsmoRoleOwners[FSMORoles.PDC] == result.rItems[0].pName, "IDL_DRSCrackNames: DS_LIST_ROLES: failed to verify PDCE owner." ); testSite.Assert.IsTrue( domain.FsmoRoleOwners[FSMORoles.RidAllocation] == result.rItems[0].pName, "IDL_DRSCrackNames: DS_LIST_ROLES: failed to verify RID allocation owner." ); testSite.Assert.IsTrue( domain.FsmoRoleOwners[FSMORoles.Infrastructure] == result.rItems[0].pName, "IDL_DRSCrackNames: DS_LIST_ROLES: failed to verify Infrastructure owner." ); } }
/// <summary> /// Get the DSName of FSMO Role object /// </summary> /// <param name="domain">Root Domain</param> /// <param name="role">The FSMO role</param> /// <returns>DSName of the FSMO role object</returns> public static DSNAME GetFsmoRoleObject(DsDomain domain, FSMORoles role) { throw new NotImplementedException(); }