private void VerifyDomainControllerInfo()

in TestSuites/ADFamily/src/Adapter/MS-NRPC/ServerRoleCaptureCode.cs [6725:7691]


        private void VerifyDomainControllerInfo(
            _DOMAIN_CONTROLLER_INFOW domainControllerInfo,
            bool recipientIsDc,
            DomainNameType domainNameType)
        {
            string domainControllerName = domainControllerInfo.DomainControllerName.Replace(@"\\", string.Empty);
            bool isPrefixValid = domainControllerInfo.DomainControllerName.StartsWith(@"\\", StringComparison.OrdinalIgnoreCase);

            if (domainNameType == DomainNameType.TrustedDomainName)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R50,
                    DomainControllerName: {0}",
                    domainControllerName);

                bool isDomainNameCorrect = domainControllerName.Replace(@"\\", string.Empty).Equals(
                    trustDCNetBiosName, StringComparison.OrdinalIgnoreCase)
                    || domainControllerName.Replace(@"\\", string.Empty).Equals(
                    trustDCName, StringComparison.OrdinalIgnoreCase);
                bool isVerifyR50 = isPrefixValid && isDomainNameCorrect;

                // Verify MS-NRPC requirement:  MS-NRPC_R50.
                // The null-terminated and UTF-16 are set in stack.
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR50,
                    50,
                    @"[In DOMAIN_CONTROLLER_INFOW structure] DomainControllerName:  A null-terminated UTF-16 string that 
                    contains a NetBIOS or fully qualified domain name (FQDN) (2) of the DC, prefixed with ""\\"".");
            }
            else
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R50,
                    DomainControllerName: {0}",
                    domainControllerName);

                bool isDomainNameCorrect = domainControllerName.Replace(@"\\", string.Empty).Equals(
                    primaryDCNetBiosName, StringComparison.OrdinalIgnoreCase)
                    || domainControllerName.Replace(@"\\", string.Empty).Equals(
                    primaryDCName, StringComparison.OrdinalIgnoreCase)
                    || domainControllerName.Replace(@"\\", string.Empty).Equals(
                    secondaryDCName, StringComparison.OrdinalIgnoreCase)
                    || domainControllerName.Replace(@"\\", string.Empty).Equals(
                    secondaryDCNetBiosName, StringComparison.OrdinalIgnoreCase);
            

                bool isVerifyR50 = isPrefixValid && isDomainNameCorrect;

                // Verify MS-NRPC requirement:  MS-NRPC_R50.
                // The null-terminated and UTF-16 are set in stack.
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR50,
                    50,
                    @"[In DOMAIN_CONTROLLER_INFOW structure] DomainControllerName:  A null-terminated UTF-16 string that 
                    contains a NetBIOS or fully qualified domain name (FQDN) (2) of the DC, prefixed with ""\\"".");
            }

            string domainControllerAdress = domainControllerInfo.DomainControllerAddress;
            DomainControllerAddressType_Values domainControllercAddressType = domainControllerInfo.DomainControllerAddressType;
            bool isIpAddress = false;
            bool isNetBiosName = false;

            // Remove the leading backslashes in dcAddress if it exists.
            string actualDcAddress = RemoveLeadingBackslash(domainControllerAdress);

            if (domainControllercAddressType == DomainControllerAddressType_Values.IpAddress)
            {
                // Ipv4 or ipv6 format.
                if (domainNameType == DomainNameType.TrustedDomainName)
                {
                    string validIpv4AddrsForTdc = Site.Properties["Common.TDC.IPAddress"];
                    string validIpv6AddrsForTdc = Site.Properties["MS_NRPC.SUT.ValidAddrsForTdc.IP.V6"];

                    isIpAddress = validIpv4AddrsForTdc.Equals(actualDcAddress, StringComparison.OrdinalIgnoreCase)
                        || validIpv6AddrsForTdc.Equals(actualDcAddress, StringComparison.OrdinalIgnoreCase);
                }
                else
                {
                    string validIpv4Addrs = Site.Properties["Common.WritableDC1.IPAddress"];
                    string validIpv6Addrs = Site.Properties["MS_NRPC.SUT.Primary.ValidAddrs.IP.V6"];
                    string valisSdcAddrs = Site.Properties["Common.WritableDC2.IPAddress"];

                    isIpAddress = validIpv4Addrs.Equals(actualDcAddress, StringComparison.OrdinalIgnoreCase)
                        || validIpv6Addrs.Equals(actualDcAddress, StringComparison.OrdinalIgnoreCase)
                        || valisSdcAddrs.Equals(actualDcAddress, StringComparison.OrdinalIgnoreCase);
                }

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R54,
                    dcAdress: {0}",
                    domainControllerAdress);

                // Verify MS-NRPC requirement: MS-NRPC_R54.
                Site.CaptureRequirementIfIsTrue(
                    isIpAddress,
                    54,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When the value in DomainControllerAddressType parameter is
                    0x00000001, it means the address is a string that contains an IP address in dotted-decimal notation
                    (for example, 192.168.0.1).<8>");

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R103394,
                    dcAdress: {0}",
                    domainControllerAdress);

                // Verify MS-NRPC requirement: MS-NRPC_R103394.
                if (PDCIsWindows)
                {
                    Site.CaptureRequirementIfIsTrue(
                        isIpAddress,
                        103394,
                        @"<154> Section 3.5.5.2.3: If the IP address of the DC to which the message was sent is known
                        from the underlying transport protocol, that address is used to set the DomainControllerAddress
                        field.");
                }
            }
            else if (domainControllercAddressType == DomainControllerAddressType_Values.NetBiosName)
            {
                string trustedDcNetBiosName = string.Empty;

                if (domainNameType == DomainNameType.TrustedDomainName)
                {
                    trustedDcNetBiosName = Site.Properties["Common.TDC.NetbiosName"];
                }
                else
                {
                    trustedDcNetBiosName = Site.Properties["Common.WritableDC1.NetbiosName"];
                }

                // Judge whether the dc name is valid.
                isNetBiosName = trustedDcNetBiosName.Equals(actualDcAddress, StringComparison.OrdinalIgnoreCase);
            }

            if (isIpAddress)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "Verify MS-NRPC_R103206");

                // Verify MS-NRPC requirement: MS-NRPC_R103206.
                Site.CaptureRequirementIfAreEqual<DomainControllerAddressType_Values>(
                    DomainControllerAddressType_Values.IpAddress,
                    domainControllerInfo.DomainControllerAddressType,
                    103206,
                    @"[In DsrGetDcName (Opnum 20), Using these response messages, the DsrGetDcName populates the
                    returned DOMAIN_CONTROLLER_INFOW structure (section 2.2.1.2.1) as follows:] The
                    DomainControllerInfo.DomainControllerAddressType field MUST be set to 0x00000001 if the
                    DomainControllerAddress field is set to the IP address of the DC.");
            }

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R52,
                isIpAddress: {0},
                isNetBiosName: {1}",
                isIpAddress,
                isNetBiosName);

            // Verify MS-NRPC requirement:  MS-NRPC_R52.
            Site.CaptureRequirementIfIsTrue(
                isIpAddress || isNetBiosName,
                52,
                @"[In DOMAIN_CONTROLLER_INFOW structure]DomainControllerAddress:The string can be either a textual
                representation of an IPv4/IPv6 address<7> or the NetBIOS name of the DC, determined by the
                DomainControllerAddressType field.");

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R51,
                isIpAddress: {0},
                isNetBiosName: {1}",
                isIpAddress,
                isNetBiosName);

            // Verify MS-NRPC requirement:  MS-NRPC_R51.
            // According to the TD, DC address can be ipv4, ipv6 or the NetBIOS name of the DC format.
            // Configure the corresponding IP address or NetBIOS name which is prefixed with \\,
            // so verify the received IP address or NetBIOS name is right.
            Site.CaptureRequirementIfIsTrue(
                isIpAddress || isNetBiosName,
                51,
                @"[In DOMAIN_CONTROLLER_INFOW structure] DomainControllerAddress:  A pointer to a null-terminated 
                Unicode string that contains the DC address, prefixed with ""\\"".");

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R53,
                dcAddressType: {0}",
                (uint)domainControllercAddressType);

            bool isVerifyR53 = (domainControllercAddressType == DomainControllerAddressType_Values.IpAddress)
                || (domainControllercAddressType == DomainControllerAddressType_Values.NetBiosName);

            // Verify MS-NRPC requirement:  MS-NRPC_R53.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR53,
                53,
                @"[In DOMAIN_CONTROLLER_INFOW structure]DomainControllerAddressType:  A 32-bit value indicating the
                DC address type, which MUST be one, and only one, of the following[0x00000001,0x00000002].");

            System.Guid domainGuid = domainControllerInfo.DomainGuid;
            Guid expectedDomainGuid = Guid.Empty;

            if (domainNameType == DomainNameType.TrustedDomainName)
            {
                expectedDomainGuid = TrustDomainGuid;
            }
            else
            {
                expectedDomainGuid = new Guid(PrimaryDomainSrvGUID);
            }

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-NRPC_R58");

            // Verify MS-NRPC requirement:  MS-NRPC_R58.
            Site.CaptureRequirementIfAreEqual<string>(
                expectedDomainGuid.ToString(),
                domainGuid.ToString(),
                58,
                @"[In DOMAIN_CONTROLLER_INFOW structure]DomainGuid:  A globally unique identifier (GUID) structure
                that contains an identifier for the domain.");
            

            string domainName = domainControllerInfo.DomainName;
            bool isDomainNameValid = false;

            if (domainNameType == DomainNameType.TrustedDomainName)
            {
                isDomainNameValid = domainName.Equals(TrustDomainDnsName, StringComparison.OrdinalIgnoreCase)
                    || domainName.Equals(trustDomainNetBiosName, StringComparison.OrdinalIgnoreCase);
            }
            else
            {
                isDomainNameValid = domainName.Equals(primaryDomainNetBiosName, StringComparison.OrdinalIgnoreCase)
                    || domainName.Equals(PrimaryDomainDnsName, StringComparison.OrdinalIgnoreCase);
            }

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R62,
                DomainName: {0}",
                domainName);

            // Verify MS-NRPC requirement:  MS-NRPC_R62.
            Site.CaptureRequirementIfIsTrue(
                isDomainNameValid,
                62,
                @"[In DOMAIN_CONTROLLER_INFOW structure]DomainName:  A Unicode string that contains the NetBIOS or
                fully qualified domain name (FQDN) (2) of the domain.");

            string dnsForestName = domainControllerInfo.DnsForestName;
            string expectedForestName = string.Empty;

            if (domainNameType == DomainNameType.TrustedDomainName)
            {
                expectedForestName = TrustDomainDnsName;
            }
            else
            {
                expectedForestName = PrimaryDomainDnsName;
            }

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-NRPC_R63");

            // Verify MS-NRPC requirement:  MS-NRPC_R63.
            Site.CaptureRequirementIfAreEqual<string>(
                expectedForestName.ToLower(CultureInfo.InvariantCulture),
                dnsForestName.ToLower(CultureInfo.InvariantCulture),
                63,
                @"[In DOMAIN_CONTROLLER_INFOW structure]DnsForestName:  A pointer to a null-terminated Unicode string
                that contains the fully qualified domain name (FQDN) of the forest.");

            uint flags = domainControllerInfo.Flags;

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // This is the value when all unused bits are set, and all used bits are clear.
            uint allUnusedBits = ~(uint)
                (0x00000001             // A
                | 0x00000004            // B
                | 0x00000008            // C
                | 0x00000010            // D
                | 0x00000020            // E
                | 0x00000040            // F
                | 0x00000080            // G
                | 0x00000100            // H
                | 0x00000200            // I
                | 0x00000400            // J
                | 0x00000800            // K
                | 0x00001000            // L
                | 0x00002000            // P
                | 0x00004000            // Q
                | 0x00008000            // R
                | 0x00010000            // S
                | 0x00020000            // T
                | 0x20000000            // M
                | 0x40000000            // N
                | 0x80000000            // O
                );

            string dcname = domainControllerInfo.DomainControllerName.Replace(@"\\", string.Empty).ToLower(CultureInfo.InvariantCulture);

            // The returned DomainControllerName can be either FQDN name or NetBIOS name.
            bool isPdc = dcname.Equals(primaryDCName, StringComparison.OrdinalIgnoreCase) ||
                dcname.Equals(primaryDCNetBiosName, StringComparison.OrdinalIgnoreCase);
            bool isTrustDc = dcname.Equals(trustDCName, StringComparison.OrdinalIgnoreCase) ||
                dcname.Equals(trustDCNetBiosName, StringComparison.OrdinalIgnoreCase);

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R68,
                Flags: {0},
                DomainControllerName: {1}",
                flags,
                dcname);

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // A: 0x00000001
            // B: 0x00000004
            // D: 0x00000010
            // E: 0x00000020
            // F: 0x00000040
            // I: 0x00000200
            // P: 0x00002000
            bool isVerifyR68 = ((flags & 0x00000400) == 0)
                || (flags & (uint)(0x00000001
                | 0x00000004
                | 0x00000010
                | 0x00000020
                | 0x00000040
                | 0x00000200
                | 0x00002000)) == 0;

            // Verify MS-NRPC requirement:  MS-NRPC_R68.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR68,
                68,
                @"[In DOMAIN_CONTROLLER_INFOW structure]Flags: bit J cannot be combined with A, B, D, E, F, I, or P.");

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // A: 0x00000001
            if ((flags & (uint)0x00000001) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "Verify MS-NRPC_R70");

                // Verify MS-NRPC requirement:  MS-NRPC_R70.
                // Both PDC and TrustDC are the primary domain controller in its domain.
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    70,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When A bit in Flags field is set, the DC is the domain's
                    primary domain controller (PDC).");

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "Verify MS-NRPC_R71");

                // Verify MS-NRPC requirement:  MS-NRPC_R71.
                // J flag should not be set.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0,
                    (flags & (uint)0x00000400),
                    71,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]A flag cannot be combined with the J flag.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // B: 0x00000004
            if ((flags & (uint)0x00000004) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R72,
                    Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R72.
                // Both PDC and TrustDC contain the global catalog (GC) for the forest Active Directory.
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    72,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When B bit in Flags field is set, the DC contains the
                    global catalog (GC) for the forest Active Directory.");

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R73");

                // Verify MS-NRPC requirement:  MS-NRPC_R73.
                // J flag should not be set.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0,
                    (flags & (uint)0x00000400),
                    73,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]B flag cannot be combined with the J flag.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // C: 0x00000008
            if ((flags & (uint)0x00000008) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R74,
                    Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R74.
                // Both PDC and TrustDC support the Lightweight Directory Access Protocol (LDAP).
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    74,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When C bit in Flags field is set, the DC  supports the
                    Lightweight Directory Access Protocol (LDAP).");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // D: 0x00000010
            if ((flags & (uint)0x00000010) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R75,
                    Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R75.
                // Both PDC and TrustDC support a directory service.
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    75,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When D bit in Flags field is set, the DC supports a
                    directory service.");

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "Verify MS-NRPC_R77");

                // Verify MS-NRPC requirement:  MS-NRPC_R77.
                // J flag should not be set.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0,
                    (flags & (uint)0x00000400),
                    77,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]D flag cannot be combined with the J flag.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // E: 0x00000020
            if ((flags & (uint)0x00000020) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R76,
                    Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R76.
                // Both PDC and TrustDC are Kerberos Key Distribution Center (KDC).
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    76,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When E bit in Flags field is set,the DC is a Kerberos
                    Key Distribution Center (KDC).");

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "Verify MS-NRPC_R78");

                // Verify MS-NRPC requirement:  MS-NRPC_R78.
                // J flag should not be set.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0,
                    (flags & (uint)0x00000400),
                    78,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]E flag cannot be combined with the J flag.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // F: 0x00000040
            if ((flags & (uint)0x00000040) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R79,
                    DomainControllerInfo.Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R79.
                // Both PDC and TrustDC have an available network time service.
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    79,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When F bit in Flags field is set,the DC has a network time
                    service available.");

                // Verify MS-NRPC requirement:  MS-NRPC_R80.
                // J flag should not be set.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0,
                    (flags & (uint)0x00000400),
                    80,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]F flag cannot be combined with the J flag.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // G: 0x00000080
            if ((flags & (uint)0x00000080) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R81,
                    DomainControllerInfo.Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R81.
                // Both PDC and TrustDC are in the closest site to the client.
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    81,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When G bit in Flags field is set,the DC is in the closest
                    site to the client.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // H: 0x00000100
            if ((flags & (uint)0x00000100) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R82,
                    DomainControllerInfo.Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R82.
                // Both PDC and TrustDC have a writable directory service available.
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    82,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When H bit in Flags field is set,the DC has a writable
                    directory service available.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // I: 0x00000200
            // J: 0x00000400
            // Flag I and J cannot be set at the same time.
            bool isVerifyR84 = !(((flags & (uint)0x00000200) > 0)
                && ((flags & 0x00000400) > 0));

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R84,
                DomainControllerInfo.Flags: {0}",
                flags);

            // Verify MS-NRPC requirement:  MS-NRPC_R84.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR84,
                84,
                @"[In DOMAIN_CONTROLLER_INFOW structure]I flag cannot be combined with the J flag.");

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // A: 0x00000001
            // B: 0x00000004
            // D: 0x00000010
            // E: 0x00000020
            // F: 0x00000040
            // I: 0x00000200
            // P: 0x00002000
            // J flag cannot be combined with any of the following flags: A, B, D, E, F, I, and P.
            bool isVerifyR86 = !(((flags & (uint)(0x00000001
                | 0x00000004
                | 0x00000010
                | 0x00000020
                | 0x00000040
                | 0x00000200
                | 0x00002000)) > 0) &&
                ((flags & 0x00000400) > 0));

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R86,
                DomainControllerInfo.Flags: {0}",
                flags);

            // Verify MS-NRPC requirement:  MS-NRPC_R86.
            Site.CaptureRequirementIfIsTrue(
                isVerifyR86,
                86,
                @"[In DOMAIN_CONTROLLER_INFOW structure]J flag cannot be combined with any of the following flags: 
                A, B, D, E, F, I, and P.");

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // L: 0x00001000
            if ((flags & (uint)0x00001000) != 0)
            {
                // Verify MS-NRPC requirement:  MS-NRPC_R89.
                // Both PDC and TrustDC are writable DCs,
                // but not running Windows Server 2003 or Windows 2000 Server.
                if ((currentSutOperatingSystem != PlatformType.WindowsServer2003)
                    && (currentSutOperatingSystem != PlatformType.WindowsServer2000))
                {
                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R89,
                        DomainControllerInfo.Flags: {0},
                        DomainControllerName: {1}",
                        flags,
                        dcname);

                    Site.CaptureRequirementIfIsTrue(
                        isPdc || isTrustDc,
                        89,
                        @"[In DOMAIN_CONTROLLER_INFOW structure]When L bit in Flags field is set, the server is a
                        writable DC, but is not running Windows Server 2003 or Windows 2000 Server.<11>");
                }
            }

            if (HelperIsDnsName(domainControllerInfo.DomainControllerName))
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R103219,
                    DomainControllerInfo.Flags: {0}",
                    flags);

                // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
                //                     1                   2                   3  
                // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
                // M: 0x20000000
                bool isVerifyR103219 = (flags & (uint)0x20000000) != 0;

                // Verify MS-NRPC requirement:  MS-NRPC_R103219.
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR103219,
                    103219,
                    @"[In DsrGetDcName (Opnum 20), Using these response messages, the DsrGetDcName populates the
                    returned DOMAIN_CONTROLLER_INFOW  structure (section 2.2.1.2.1) as follows:] Additionally,
                    the following flags are set in the DomainControllerInfo.Flags field: The flag M MUST be set
                    if the DomainControllerInfo.DomainControllerName field is set to the fully qualified domain name
                    (FQDN) (1) of the DC.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // M: 0x20000000
            if ((flags & (uint)0x20000000) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R91,
                    DomainControllerName: {0}",
                    domainControllerInfo.DomainControllerName);

                // Verify MS-NRPC requirement:  MS-NRPC_R91.
                Site.CaptureRequirementIfIsTrue(
                    HelperIsDnsName(domainControllerInfo.DomainControllerName),
                    91,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When M bit in Flags field is set, the DC's name
                    is a DNS name.");
            }

            if (HelperIsDnsName(domainControllerInfo.DomainName))
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R103220,
                    DomainControllerInfo.Flags: {0}",
                    flags);

                // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
                //                     1                   2                   3  
                // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
                // N: 0x40000000
                bool isVerifyR103220 = (flags & (uint)0x40000000) != 0;

                // Verify MS-NRPC requirement:  MS-NRPC_R103220.
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR103220,
                    103220,
                    @"[In DsrGetDcName (Opnum 20), Using these response messages, the DsrGetDcName populates the
                    returned DOMAIN_CONTROLLER_INFOW structure (section 2.2.1.2.1) as follows: Additionally, the
                    following flags are set in the DomainControllerInfo.Flags field: ] The flag N MUST be set if
                    the DomainControllerInfo.DomainName field is set to the fully qualified domain name (FQDN) (2)
                    of the domain.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // N: 0x40000000
            if ((flags & (uint)0x40000000) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R92,
                    DomainName: {0}",
                    domainControllerInfo.DomainName);

                // Verify MS-NRPC requirement:  MS-NRPC_R92.
                Site.CaptureRequirementIfIsTrue(
                    HelperIsDnsName(domainControllerInfo.DomainName),
                    92,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When N bit in Flags field is set, the DC's domain
                    name is a DNS name.");
            }

            if (!string.IsNullOrEmpty(domainControllerInfo.DnsForestName))
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R103220,
                    DomainControllerInfo.Flags: {0}",
                    flags);

                // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
                //                     1                   2                   3  
                // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
                // O: 0x80000000
                bool isVerifyR103221 = (flags & (uint)0x80000000) != 0;

                // Verify MS-NRPC requirement:  MS-NRPC_R103221.
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR103221,
                    103221,
                    @"[In DsrGetDcName (Opnum 20), Using these response messages, the DsrGetDcName populates
                    the returned DOMAIN_CONTROLLER_INFOW structure (section 2.2.1.2.1) as follows: Additionally,
                    the following flags are set in the DomainControllerInfo.Flags field: ] The flag O MUST be set
                    if the DomainControllerInfo.DnsForestName field is set.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // O: 0x80000000
            if ((flags & (uint)0x80000000) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R93,
                    DnsForestName: {0}",
                    domainControllerInfo.DnsForestName);

                // Verify MS-NRPC requirement:  MS-NRPC_R93.
                Site.CaptureRequirementIfIsTrue(
                    HelperIsDnsName(domainControllerInfo.DnsForestName),
                    93,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When O bit in Flags field is set, the DC's forest name
                    is a DNS name.");
            }

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // P: 0x00002000
            if ((flags & (uint)0x00002000) != 0)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R94,
                    DomainControllerInfo.Flags: {0},
                    DomainControllerName: {1}",
                    flags,
                    dcname);

                // Verify MS-NRPC requirement:  MS-NRPC_R94.
                // Both PDC and TrustDC have an Active Directory Web Service available.
                Site.CaptureRequirementIfIsTrue(
                    isPdc || isTrustDc,
                    94,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]When P bit in Flags field is set, the DC has an Active
                    Directory Web Service available.");
            }

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R95,
                Flags: {0}",
                flags);

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // J: 0x00000400
            // P: 0x00002000
            bool isPAndJSet = ((flags & (uint)0x00002000) != 0)
                && ((flags & (uint)0x00000400) != 0);

            // Verify MS-NRPC requirement:  MS-NRPC_R95.
            // P and J flags can not be set at the same time.
            Site.CaptureRequirementIfIsFalse(
                isPAndJSet,
                95,
                @"[In DOMAIN_CONTROLLER_INFOW structure]P flag cannot be combined with the J flag. <12>");

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                @"Verify MS-NRPC_R97,
                Flags: {0}",
                flags);

            // Flags: A set of bit flags in little-endian format that describes the features and roles of the DC.
            //                     1                   2                   3  
            // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
            // O N M 0 0 0 0 0 0 0 0 0 0 0 T S R Q P L K J I H G F E D C B 0 A
            // E: 0x00000020
            // S: 0x00010000
            // T: 0x00020000
            if ((flags & (uint)0x00020000) != 0)
            {
                bool isEAndSSet = ((flags & (uint)0x00000020) != 0)
                    && ((flags & (uint)0x00010000) != 0);

                // Verify MS-NRPC requirement:  MS-NRPC_R103222.
                Site.CaptureRequirementIfIsTrue(
                    isEAndSSet,
                    103222,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]If T bit is set, bit S and bit E must also be set.");
            }

            // Verify MS-NRPC requirement:  MS-NRPC_R97.
            // All other bits[except A to S bits]MUST be set to zero, which is duplicate with 67.
            Site.CaptureRequirementIfAreEqual<uint>(
                0,
                (flags & allUnusedBits),
                97,
                @"[In DOMAIN_CONTROLLER_INFOW structure]Flags:All other bits[except A to T bits]MUST be set to zero.");

            // Add the debug information.
            Site.Log.Add(
                LogEntryKind.Debug,
                "Verify MS-NRPC_R99");

            // Verify MS-NRPC requirement:  MS-NRPC_R99.
            // The condition that there is a configured associated site.
            Site.CaptureRequirementIfAreEqual<string>(
                defaultSiteName.ToLower(CultureInfo.InvariantCulture),
                domainControllerInfo.DcSiteName.ToLower(CultureInfo.InvariantCulture),
                99,
                @"[In DOMAIN_CONTROLLER_INFOW structure]DcSiteName:  Pointer to a null-terminated Unicode string that
                contains the site name that is associated with the DC.");

            if (recipientIsDc)
            {
                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    "Verify MS-NRPC_R101");

                // Verify MS-NRPC requirement:  MS-NRPC_R101.
                // NULL string in the TD is tested by empty string here.
                Site.CaptureRequirementIfAreEqual(
                    defaultSiteName,
                    domainControllerInfo.ClientSiteName,
                    101,
                    @"[In DOMAIN_CONTROLLER_INFOW structure]ClientSiteName:  Pointer to a null-terminated Unicode string
                that contains the client's site name.");
            }
        }