void VerifyCrackNamesListGlobalCatalogServers(
            DsServer dc,
            DRS_MSG_CRACKREQ req,
            DRS_MSG_CRACKREPLY?reply)
        {
            DsServer[] servers = ldapAd.ListGcServers(dc);
            testSite.Assert.IsTrue(
                reply.Value.V1.pResult[0].cItems == servers.Length,
                "IDL_DRSCrackNames: DS_LIST_GLOBAL_CATALOG_SERVERS: wrong server count, expect:{0}, got:{1}",
                servers.Length,
                reply.Value.V1.pResult[0].cItems
                );

            string[] siteDns      = new string[servers.Length];
            string[] dnsHostNames = new string[servers.Length];
            for (int i = 0; i < servers.Length; ++i)
            {
                siteDns[i]      = servers[i].Site.DN.ToLower();
                dnsHostNames[i] = servers[i].DnsHostName.ToLower();
            }

            string[] drsrSiteDns      = new string[reply.Value.V1.pResult[0].cItems];
            string[] drsrDnsHostNames = new string[reply.Value.V1.pResult[0].cItems];
            for (int i = 0; i < reply.Value.V1.pResult[0].cItems; ++i)
            {
                drsrSiteDns[i]      = reply.Value.V1.pResult[0].rItems[i].pName.ToLower();
                drsrDnsHostNames[i] = reply.Value.V1.pResult[0].rItems[i].pDomain.ToLower();
                testSite.Assert.IsTrue(
                    reply.Value.V1.pResult[0].rItems[i].status == DS_NAME_ERROR.DS_NAME_NO_ERROR,
                    "IDL_DRSCrackNames: DS_LIST_GLOBAL_CATALOG_SERVERS: return status should be 0, got {0}",
                    reply.Value.V1.pResult[0].rItems[i].status
                    );
            }

            testSite.Assert.IsTrue(
                DrsrHelper.IsStringArrayEqual(siteDns, drsrSiteDns),
                "IDL_DRSCrackNames: DS_LIST_GLOBAL_CATALOG_SERVERS: failed to verify site DNs."
                );

            testSite.Assert.IsTrue(
                DrsrHelper.IsStringArrayEqual(dnsHostNames, drsrDnsHostNames),
                "IDL_DRSCrackNames: DS_LIST_GLOBAL_CATALOG_SERVERS: failed to verify server DNS host names."
                );
        }
        void VerifyCrackNamesListServersForDomainInSite(
            DsServer dc,
            DRS_MSG_CRACKREQ req,
            DRS_MSG_CRACKREPLY?reply)
        {
            string domainDn = req.V1.rpNames[0];
            string siteDn   = req.V1.rpNames[1];

            DsServer[] servers = ldapAd.ListServersForDomainInSite(dc, domainDn, siteDn);

            testSite.Assert.IsTrue(
                reply.Value.V1.pResult[0].cItems == servers.Length,
                "IDL_DRSCrackNames: DS_LIST_SERVERS_FOR_DOMAIN_IN_SITE: wrong server count, expect:{0}, got:{1}",
                servers.Length,
                reply.Value.V1.pResult[0].cItems
                );

            string[] serverDns = new string[servers.Length];
            for (int i = 0; i < servers.Length; ++i)
            {
                serverDns[i] = servers[i].ServerObjectName;
            }

            string[] drsrServers = new string[reply.Value.V1.pResult[0].cItems];
            for (int i = 0; i < reply.Value.V1.pResult[0].cItems; ++i)
            {
                drsrServers[i] = reply.Value.V1.pResult[0].rItems[i].pName;
                testSite.Assert.IsTrue(
                    reply.Value.V1.pResult[0].rItems[i].status == DS_NAME_ERROR.DS_NAME_NO_ERROR,
                    "IDL_DRSCrackNames: DS_LIST_SERVERS_FOR_DOMAIN_IN_SITE: return status should be 0, got {0}",
                    reply.Value.V1.pResult[0].rItems[i].status
                    );
            }

            testSite.Assert.IsTrue(
                DrsrHelper.IsStringArrayEqual(serverDns, drsrServers),
                "IDL_DRSCrackNames: DS_LIST_SERVERS_FOR_DOMAIN_IN_SITE: failed to verify servers in site {0}",
                siteDn
                );
        }
        void VerifyCrackNamesListNcs(
            DsServer dc,
            DRS_MSG_CRACKREQ req,
            DRS_MSG_CRACKREPLY?reply)
        {
            string[] ncs     = ldapAd.ListNCs(dc);
            string[] drsrNcs = new string[reply.Value.V1.pResult[0].cItems];
            for (int i = 0; i < reply.Value.V1.pResult[0].cItems; ++i)
            {
                drsrNcs[i] = reply.Value.V1.pResult[0].rItems[i].pName;
                testSite.Assert.IsTrue(
                    reply.Value.V1.pResult[0].rItems[i].status == DS_NAME_ERROR.DS_NAME_NO_ERROR,
                    "IDL_DRSCrackNames: DS_LIST_NCS: return status should be 0, got {0}",
                    reply.Value.V1.pResult[0].rItems[i].status
                    );
            }

            testSite.Assert.IsTrue(
                DrsrHelper.IsStringArrayEqual(ncs, drsrNcs),
                "IDL_DRSCrackNames: DS_LIST_NCS: failed to verify NCs."
                );
        }
        void VerifyCrackNamesListDomainsInSite(
            DsServer dc,
            DRS_MSG_CRACKREQ req,
            DRS_MSG_CRACKREPLY?reply)
        {
            string siteDn = req.V1.rpNames[0];
            DsSite site   = ldapAd.GetSite(dc, siteDn);

            string[] domains = new string[site.Domains.Length];

            testSite.Assert.IsTrue(
                reply.Value.V1.pResult[0].cItems == domains.Length,
                "IDL_DRSCrackNames: DS_LIST_DOMAINS_IN_SITE: wrong domain count, expect:{0}, got:{1}",
                domains.Length,
                reply.Value.V1.pResult[0].cItems
                );

            for (int i = 0; i < site.Domains.Length; ++i)
            {
                domains[i] = site.Domains[i].Name;
            }

            string[] drsrDomains = new string[reply.Value.V1.pResult[0].cItems];
            for (int i = 0; i < reply.Value.V1.pResult[0].cItems; ++i)
            {
                drsrDomains[i] = reply.Value.V1.pResult[0].rItems[i].pName;
                testSite.Assert.IsTrue(
                    reply.Value.V1.pResult[0].rItems[i].status == DS_NAME_ERROR.DS_NAME_NO_ERROR,
                    "IDL_DRSCrackNames: DS_LIST_DOMAINS_IN_SITE: return status should be 0, got {0}",
                    reply.Value.V1.pResult[0].rItems[i].status
                    );
            }

            testSite.Assert.IsTrue(
                DrsrHelper.IsStringArrayEqual(domains, drsrDomains),
                "IDL_DRSCrackNames: DS_LIST_DOMAINS_IN_SITE: failed to verify servers in site {0}",
                siteDn
                );
        }
        void VerifyCrackNamesListDomains(
            DsServer dc,
            DRS_MSG_CRACKREQ req,
            DRS_MSG_CRACKREPLY?reply)
        {
            DsDomain[] domains = ldapAd.ListDomains(dc);

            testSite.Assert.IsTrue(
                reply.Value.V1.pResult[0].cItems == domains.Length,
                "IDL_DRSCrackNames: DS_LIST_DOMAINS: wrong domain count, expect:{0}, got:{1}",
                domains.Length,
                reply.Value.V1.pResult[0].cItems
                );

            string[] domainDns = new string[domains.Length];
            for (int i = 0; i < domains.Length; ++i)
            {
                domainDns[i] = domains[i].Name;
            }

            DS_NAME_RESULTW result = reply.Value.V1.pResult[0];

            string[] listDomainDns = new string[result.cItems];
            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_DOMAINS: return status should be 0, got {0}",
                    result.rItems[i].status
                    );
                listDomainDns[i] = result.rItems[i].pName;
            }

            testSite.Assert.IsTrue(
                DrsrHelper.IsStringArrayEqual(domainDns, listDomainDns),
                "IDL_DRSCrackNames: DS_LIST_DOMAINS: failed to verify domain DNs."
                );
        }
        // Verify DS_LIST_SITES of IDL_DRSCrackNames
        void VerifyCrackNamesListAllSites(
            DsServer dc,
            DRS_MSG_CRACKREQ req,
            DRS_MSG_CRACKREPLY?reply)
        {
            DsSite[] sites = ldapAd.ListSites(dc);

            testSite.Assert.IsTrue(
                reply.Value.V1.pResult[0].cItems == sites.Length,
                "IDL_DRSCrackNames: DS_LIST_SITES: wrong site count, expect:{0}, got:{1}",
                sites.Length,
                reply.Value.V1.pResult[0].cItems
                );

            string[] siteDns = new string[sites.Length];
            for (int i = 0; i < sites.Length; ++i)
            {
                siteDns[i] = sites[i].DN;
            }

            string[] listSiteDns = new string[reply.Value.V1.pResult[0].cItems];
            for (int i = 0; i < reply.Value.V1.pResult[0].cItems; ++i)
            {
                testSite.Assert.IsTrue(
                    reply.Value.V1.pResult[0].rItems[i].status == DS_NAME_ERROR.DS_NAME_NO_ERROR,
                    "IDL_DRSCrackNames: DS_LIST_SITES: return status should be 0, got {0}",
                    reply.Value.V1.pResult[0].rItems[i].status
                    );

                listSiteDns[i] = reply.Value.V1.pResult[0].rItems[i].pName;
            }

            testSite.Assert.IsTrue(
                DrsrHelper.IsStringArrayEqual(siteDns, listSiteDns),
                "IDL_DRSCrackNames: DS_LIST_SITES: failed to verify site DNs"
                );
        }