private void VerifyNetlogonValidationSamInfo2()

in TestSuites/ADFamily/src/Adapter/MS-NRPC/ServerRoleCaptureCode.cs [2232:3163]


        private void VerifyNetlogonValidationSamInfo2(
            HRESULT hresult,
            _NETLOGON_VALIDATION_SAM_INFO2 validationSamInfo,
            _NETLOGON_LOGON_INFO_CLASS logonLevel,
            long expectedPasswordLastSet,
            string expectedEffectiveName,
            string expectedLogonScript,
            string expectedProfilePath,
            string expectedHomeDirectory,
            string expectedHomeDirectoryDrive,
            ushort expectedBadPasswordCount,
            ushort expectedLogonCount)
        {
            if (hresult == HRESULT.ERROR_SUCCESS)
            {
                _RPC_UNICODE_STRING logonScript = validationSamInfo.LogonScript;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Convert the _RPC_UNICODE_STRING structure to string.
                    string actualLogonScript = GetRpcUnicodeString(logonScript);
                    bool isLogonScriptValid;
                    if (null == expectedLogonScript)
                    {
                        isLogonScriptValid = null == actualLogonScript;
                    }
                    else
                    {
                        isLogonScriptValid = logonScript.GetType() == typeof(_RPC_UNICODE_STRING)
                        && actualLogonScript.Equals(expectedLogonScript, StringComparison.OrdinalIgnoreCase);
                    }

                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R104418,
                        actual LogonScript: {0},
                        expected LogonScript: {1}",
                        actualLogonScript,
                        expectedLogonScript);

                    // Verify MS-NRPC requirement:  MS-NRPC_R104418.
                    Site.CaptureRequirementIfIsTrue(
                        isLogonScriptValid,
                        "MS-PAC",
                        104418,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]LogonScript:  A RPC_UNICODE_STRING structure
                        that contains the user account's scriptPath attribute ([MS-ADA3] section 2.231) value for
                        interactive logon");
                }

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkInformation)
                {
                    // Verify requirement : MS-NRPC_R104419, MS-NRPC_R104420.
                    string isR104419Implemented = Site.Properties["MS_NRPC.SHOULDMAY.R104419Implementation"];
                    if (PDCIsWindows)
                    {
                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104420,
                            LogonScript.Length: {0}",
                            logonScript.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104420.
                        Site.CaptureRequirementIfAreEqual<ushort>(
                            0,
                            logonScript.Length,
                            "MS-PAC",
                            104420,
                            @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]LogonScript: in Windows,[it]is zero for
                            network logon.");

                        if (null == isR104419Implemented)
                        {
                            Site.Properties.Add("MS_NRPC.SHOULDMAY.R104419Implementation", bool.TrueString);
                            isR104419Implemented = bool.TrueString;
                        }
                    }

                    if (null != isR104419Implemented)
                    {
                        bool implement = bool.Parse(isR104419Implemented);
                        bool isSatisfied = logonScript.Length == 0;

                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104419,
                            LogonScript.Length: {0}",
                            logonScript.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104419.
                        Site.CaptureRequirementIfAreEqual<bool>(
                            implement,
                            isSatisfied,
                            "MS-PAC",
                            104419,
                            string.Format(CultureInfo.InvariantCulture, 
                                @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]LogonScript:
                                SHOULD be zero for network logon.
                                This requirement is {0} implemented.",
                                implement ? string.Empty : "not"));
                    }
                }

                _OLD_LARGE_INTEGER passwordLastSet = validationSamInfo.PasswordLastSet;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Convert _OLD_LARGE_INTEGER structure to Int64.
                    long actualPasswordLastSetInt = GetInt64ValueFromOldLargeInteger(passwordLastSet);

                    // Type _OLD_LARGE_INTEGER in NRPC is corresponding to type FILETIME in PAC.
                    bool isPasswordLastSetValid = (passwordLastSet.GetType() == typeof(_OLD_LARGE_INTEGER))
                        && actualPasswordLastSetInt.Equals(expectedPasswordLastSet);

                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R104397,
                        actual PasswordLastSet: {0},
                        expected PasswordLastSet: {1}",
                        actualPasswordLastSetInt,
                        expectedPasswordLastSet);

                    // Verify MS-NRPC requirement:  MS-NRPC_R104397.
                    Site.CaptureRequirementIfIsTrue(
                        isPasswordLastSetValid,
                        "MS-PAC",
                        104397,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]PasswordLastSet:  A FILETIME structure
                        that contains the user account's pwdLastSet attribute ([MS-ADA3] section 2.174) value
                        for interactive logon");
                }

                _OLD_LARGE_INTEGER passwordCanChange = validationSamInfo.PasswordCanChange;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "Verify MS-NRPC_R104402");

                    // Verify MS-NRPC requirement:  MS-NRPC_R104402.
                    // Type _OLD_LARGE_INTEGER in NRPC is corresponding to type FILETIME in PAC.
                    // It.s only used to verify the type not the content because other
                    // protocol is used to get the content.
                    Site.CaptureRequirementIfAreEqual<Type>(
                        typeof(_OLD_LARGE_INTEGER),
                        passwordCanChange.GetType(),
                        "MS-PAC",
                        104402,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]PasswordCanChange: A FILETIME
                        structure that contains the time at which the client's password is allowed to
                        change for interactive logon");
                }

                _OLD_LARGE_INTEGER passwordMustChange = validationSamInfo.PasswordMustChange;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "Verify MS-NRPC_R104406");

                    // Verify MS-NRPC requirement:  MS-NRPC_R104406.
                    // Type _OLD_LARGE_INTEGER in NRPC is corresponding to type FILETIME in PAC.
                    // It is only used to verify the type not the content because other
                    // protocol is used to get the content.
                    Site.CaptureRequirementIfAreEqual<Type>(
                        typeof(_OLD_LARGE_INTEGER),
                        passwordMustChange.GetType(),
                        "MS-PAC",
                        104406,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]PasswordMustChange: A FILETIME structure that
                        contains the time at which the client's password expires for interactive logon.");
                }

                _RPC_UNICODE_STRING effectiveName = validationSamInfo.EffectiveName;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Convert the _RPC_UNICODE_STRING structure to string.
                    string actualEffectiveName = GetRpcUnicodeString(effectiveName);
                    bool isEffectiveNameValid = (effectiveName.GetType() == typeof(_RPC_UNICODE_STRING))
                        && actualEffectiveName.Equals(expectedEffectiveName, StringComparison.OrdinalIgnoreCase);

                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R104411,
                        actual EffectiveName: {0},
                        expected EffectiveName: {1}",
                        actualEffectiveName,
                        expectedEffectiveName);

                    // Verify MS-NRPC requirement:  MS-NRPC_R104411.
                    Site.CaptureRequirementIfIsTrue(
                        isEffectiveNameValid,
                        "MS-PAC",
                        104411,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]EffectiveName:  A RPC_UNICODE_STRING structure
                        that contains the user account's samAccountName attribute ([MS-ADA3] section 2.221) value for
                        interactive logon");
                }

                _RPC_UNICODE_STRING fullName = validationSamInfo.FullName;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        "Verify MS-NRPC_R104414");

                    // Verify MS-NRPC requirement:  MS-NRPC_R104414.
                    // It is only used to verify the type not the content because other
                    // protocol is used to get the content.
                    Site.CaptureRequirementIfAreEqual<Type>(
                        typeof(_RPC_UNICODE_STRING),
                        fullName.GetType(),
                        "MS-PAC",
                        104414,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]FullName:  A RPC_UNICODE_STRING structure that
                        contains the user account's full name for interactive logon");
                }

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkInformation)
                {
                    // Verify requirement : MS-NRPC_R104415, MS-NRPC_R104416.
                    string isR104415Implemented = Site.Properties["MS_NRPC.SHOULDMAY.R104415Implementation"];
                    if (PDCIsWindows)
                    {
                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104416,
                            FullName.Length: {0}",
                            fullName.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104416.
                        Site.CaptureRequirementIfAreEqual<ushort>(
                            0,
                            fullName.Length,
                            "MS-PAC",
                            104416,
                            @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]FullName: in Windows,[it]is zero for
                            network logon.");

                        if (null == isR104415Implemented)
                        {
                            Site.Properties.Add("MS_NRPC.SHOULDMAY.R104415Implementation", bool.TrueString);
                            isR104415Implemented = bool.TrueString;
                        }
                    }

                    if (null != isR104415Implemented)
                    {
                        bool implement = bool.Parse(isR104415Implemented);
                        bool isSatisfied = fullName.Length == 0;

                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104415,
                            FullName.Length: {0}",
                            fullName.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104415.
                        Site.CaptureRequirementIfAreEqual<bool>(
                            implement,
                            isSatisfied,
                            "MS-PAC",
                            104415,
                            string.Format(CultureInfo.InvariantCulture, 
                                @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]FullName:
                                SHOULD be zero for network logon.
                                This requirement is {0} implemented.",
                                implement ? string.Empty : "not"));
                    }
                }

                _RPC_UNICODE_STRING profilePath = validationSamInfo.ProfilePath;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // convert the _RPC_UNICODE_STRING structure to string.
                    string actualProfilePath = GetRpcUnicodeString(profilePath);
                    bool isProfilePathValid;
                    if (null == expectedProfilePath)
                    {
                        isProfilePathValid = null == actualProfilePath;
                    }
                    else
                    {
                        isProfilePathValid = (profilePath.GetType() == typeof(_RPC_UNICODE_STRING))
                            && actualProfilePath.Equals(expectedProfilePath, StringComparison.OrdinalIgnoreCase);
                    }

                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R104421,
                        actual ProfilePath: {0},
                        expected ProfilePath: {1}",
                        actualProfilePath,
                        expectedProfilePath);

                    // Verify MS-NRPC requirement:  MS-NRPC_R104421.
                    Site.CaptureRequirementIfIsTrue(
                        isProfilePathValid,
                        "MS-PAC",
                        104421,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]ProfilePath: A RPC_UNICODE_STRING structure
                        that contains the user account's profilePath attribute ([MS-ADA3] section 2.166) value for
                        interactive logon");
                }

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkInformation)
                {
                    // Verify requirement : MS-NRPC_R104423, MS-NRPC_R104424.
                    string isR104423Implemented = Site.Properties["MS_NRPC.SHOULDMAY.R104423Implementation"];
                    if (PDCIsWindows)
                    {
                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104424,
                            ProfilePath.Length: {0}",
                            profilePath.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104424.
                        Site.CaptureRequirementIfAreEqual<ushort>(
                            0,
                            profilePath.Length,
                            "MS-PAC",
                            104424,
                            @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]ProfilePath: in Windows,[it]is zero
                            for network logon.");

                        if (null == isR104423Implemented)
                        {
                            Site.Properties.Add("MS_NRPC.SHOULDMAY.R104423Implementation", bool.TrueString);
                            isR104423Implemented = bool.TrueString;
                        }
                    }

                    if (null != isR104423Implemented)
                    {
                        bool implement = bool.Parse(isR104423Implemented);
                        bool isSatisfied = profilePath.Length == 0;

                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104423,
                            ProfilePath.Length: {0}",
                            profilePath.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104423.
                        Site.CaptureRequirementIfAreEqual<bool>(
                            implement,
                            isSatisfied,
                            "MS-PAC",
                            104423,
                            string.Format(CultureInfo.InvariantCulture, 
                                @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]ProfilePath:
                                SHOULD be zero for network logon.
                                This requirement is {0} implemented.",
                                implement ? string.Empty : "not"));
                    }
                }

                _RPC_UNICODE_STRING homeDirectoryDrive = validationSamInfo.HomeDirectoryDrive;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Convert the _RPC_UNICODE_STRING structure to string.
                    string actualHomeDirectoryDrive = GetRpcUnicodeString(homeDirectoryDrive);
                    bool isHomeDirectoryDriveValid;
                    if (null == expectedHomeDirectoryDrive)
                    {
                        isHomeDirectoryDriveValid = null == actualHomeDirectoryDrive;
                    }
                    else
                    {
                        isHomeDirectoryDriveValid = (homeDirectoryDrive.GetType() == typeof(_RPC_UNICODE_STRING))
                            && actualHomeDirectoryDrive.Equals(
                                                               expectedHomeDirectoryDrive,
                                                               StringComparison.OrdinalIgnoreCase);
                    }

                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R104430,
                        actual HomeDirectoryDrive: {0},
                        expected HomeDirectoryDrive: {1}",
                        actualHomeDirectoryDrive,
                        expectedHomeDirectoryDrive);

                    // Verify MS-NRPC requirement:  MS-NRPC_R104430.
                    Site.CaptureRequirementIfIsTrue(
                        isHomeDirectoryDriveValid,
                        "MS-PAC",
                        104430,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]HomeDirectoryDrive: A RPC_UNICODE_STRING
                        structure that contains the user account's HomeDrive attribute ([MS-ADA1] section 2.296)
                        value for interactive logon");
                }

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkInformation)
                {
                    // Verify requirement : MS-NRPC_R104431, MS-NRPC_R104432.
                    string isR104431Implemented = Site.Properties["MS_NRPC.SHOULDMAY.R104431Implementation"];
                    if (PDCIsWindows)
                    {
                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104430,
                            HomeDirectoryDrive.Length: {0}",
                            homeDirectoryDrive.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104432.
                        Site.CaptureRequirementIfAreEqual<ushort>(
                            0,
                            homeDirectoryDrive.Length,
                            "MS-PAC",
                            104432,
                            @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]HomeDirectoryDrive: in Windows,[it]is zero
                            for network logon.");

                        if (null == isR104431Implemented)
                        {
                            Site.Properties.Add("MS_NRPC.SHOULDMAY.R104431Implementation", bool.TrueString);
                            isR104431Implemented = bool.TrueString;
                        }
                    }

                    if (null != isR104431Implemented)
                    {
                        bool implement = bool.Parse(isR104431Implemented);
                        bool isSatisfied = homeDirectoryDrive.Length == 0;

                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104431,
                            HomeDirectoryDrive.Length: {0}",
                            homeDirectoryDrive.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104431.
                        Site.CaptureRequirementIfAreEqual<bool>(
                            implement,
                            isSatisfied,
                            "MS-PAC",
                            104431,
                            string.Format(CultureInfo.InvariantCulture, 
                                @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]HomeDirectoryDrive:
                                SHOULD be zero for network logon .
                                This requirement is {0} implemented.",
                                implement ? string.Empty : "not"));
                    }
                }

                _RPC_UNICODE_STRING homeDirectory = validationSamInfo.HomeDirectory;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    // Convert the _RPC_UNICODE_STRING structure to string.
                    string actualHomeDirectory = GetRpcUnicodeString(homeDirectory);
                    bool isHomeDirectoryValid;
                    if (null == expectedHomeDirectory)
                    {
                        isHomeDirectoryValid = null == actualHomeDirectory;
                    }
                    else
                    {
                        isHomeDirectoryValid = (homeDirectory.GetType() == typeof(_RPC_UNICODE_STRING))
                            && actualHomeDirectory.Equals(expectedHomeDirectory, StringComparison.OrdinalIgnoreCase);
                    }

                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R104426,
                        actual HomeDirectory: {0},
                        expected HomeDirectory: {1}",
                        actualHomeDirectory,
                        expectedHomeDirectory);

                    // Verify MS-NRPC requirement:  MS-NRPC_R104426.
                    Site.CaptureRequirementIfIsTrue(
                        isHomeDirectoryValid,
                        "MS-PAC",
                        104426,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]HomeDirectory: A RPC_UNICODE_STRING structure
                        that contains the user account's HomeDirectory attribute ([MS-ADA1] section 2.295) value for
                        interactive logon");
                }

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkInformation)
                {
                    // Verify requirement : MS-NRPC_R104427, MS-NRPC_R104428.
                    string isR104427Implemented = Site.Properties["MS_NRPC.SHOULDMAY.R104427Implementation"];
                    if (PDCIsWindows)
                    {
                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104428,
                            HomeDirectory.Length: {0}",
                            homeDirectory.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104428.
                        Site.CaptureRequirementIfAreEqual<ushort>(
                            0,
                            homeDirectory.Length,
                            "MS-PAC",
                            104428,
                            @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]HomeDirectory: in Windows,[it]is zero for
                            network logon.");

                        if (null == isR104427Implemented)
                        {
                            Site.Properties.Add("MS_NRPC.SHOULDMAY.R104427Implementation", bool.TrueString);
                            isR104427Implemented = bool.TrueString;
                        }
                    }

                    if (null != isR104427Implemented)
                    {
                        bool implement = bool.Parse(isR104427Implemented);
                        bool isSatisfied = homeDirectory.Length == 0;

                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104427,
                            HomeDirectory.Length: {0}",
                            homeDirectory.Length);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104427.
                        Site.CaptureRequirementIfAreEqual<bool>(
                            implement,
                            isSatisfied,
                            "MS-PAC",
                            104427,
                            string.Format(CultureInfo.InvariantCulture, 
                                @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]HomeDirectory:
                                SHOULD be zero for network logon.
                                This requirement is {0} implemented.",
                                implement ? string.Empty : "not"));
                    }
                }

                ushort badPasswordCount = validationSamInfo.BadPasswordCount;

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonInteractiveInformation)
                {
                    bool isBadPasswordCountValid = (badPasswordCount.GetType() == typeof(ushort))
                        && badPasswordCount.Equals(expectedBadPasswordCount);

                    // Add the debug information.
                    Site.Log.Add(
                        LogEntryKind.Debug,
                        @"Verify MS-NRPC_R104436,
                        actual BadPasswordCount: {0},
                        expected BadPasswordCount: {1}",
                        badPasswordCount,
                        expectedBadPasswordCount);

                    // Verify MS-NRPC requirement:  MS-NRPC_R104436.
                    Site.CaptureRequirementIfIsTrue(
                        isBadPasswordCountValid,
                        "MS-PAC",
                        104436,
                        @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]BadPasswordCount: A 16-bit unsigned integer
                        that contains the user account's badPwdCount attribute ([MS-ADA1] section 2.83) value for
                        interactive logon");
                }

                if (logonLevel == _NETLOGON_LOGON_INFO_CLASS.NetlogonNetworkInformation)
                {
                    // Verify requirement : MS-NRPC_R104437, MS-NRPC_R104438.
                    string isR104437Implemented = Site.Properties["MS_NRPC.SHOULDMAY.R104437Implementation"];
                    if (PDCIsWindows)
                    {
                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104438,
                            BadPasswordCount: {0}",
                            badPasswordCount);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104438.
                        Site.CaptureRequirementIfAreEqual<ushort>(
                            0,
                            badPasswordCount,
                            "MS-PAC",
                            104438,
                            @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]BadPasswordCount:In Windows,[it] is zero for
                            network logon.");

                        if (null == isR104437Implemented)
                        {
                            Site.Properties.Add("MS_NRPC.SHOULDMAY.R104437Implementation", bool.TrueString);
                            isR104437Implemented = bool.TrueString;
                        }
                    }

                    if (null != isR104437Implemented)
                    {
                        bool implement = bool.Parse(isR104437Implemented);
                        bool isSatisfied = badPasswordCount == 0;

                        // Add the debug information.
                        Site.Log.Add(
                            LogEntryKind.Debug,
                            @"Verify MS-NRPC_R104437,
                            BadPasswordCount: {0}",
                            badPasswordCount);

                        // Verify MS-NRPC requirement:  MS-NRPC_R104437.
                        Site.CaptureRequirementIfAreEqual<bool>(
                            implement,
                            isSatisfied,
                            "MS-PAC",
                            104437,
                            string.Format(CultureInfo.InvariantCulture, 
                                @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]BadPasswordCount:
                                SHOULD be zero for network logon.
                                This requirement is {0} implemented.",
                                implement ? string.Empty : "not"));
                    }
                }

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

                // Verify MS-NRPC requirement:  MS-NRPC_R104359.
                // Type _OLD_LARGE_INTEGER in NRPC is corresponding to type FILETIME in PAC.
                Site.CaptureRequirementIfAreEqual<Type>(
                    typeof(_OLD_LARGE_INTEGER),
                    validationSamInfo.LogonTime.GetType(),
                    "MS-PAC",
                    104359,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]LogonTime: A FILETIME structure that contains the user 
                    account's lastLogon attribute ([MS-ADA1] section 2.351) value.");

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

                // Verify MS-NRPC requirement:  MS-NRPC_R104381.
                // Type _OLD_LARGE_INTEGER in NRPC is corresponding to type FILETIME in PAC.
                // I's only used to verify the type not the content because other protocol is used to get the content.
                Site.CaptureRequirementIfAreEqual<Type>(
                    typeof(_OLD_LARGE_INTEGER),
                    validationSamInfo.LogoffTime.GetType(),
                    "MS-PAC",
                    104381,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]LogoffTime:  A FILETIME structure that contains
                    the time the client's logon session should expire.");

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

                // Verify MS-NRPC requirement:  MS-NRPC_R104388.
                // Type _OLD_LARGE_INTEGER in NRPC is corresponding to type FILETIME in PAC.
                // It's only used to verify the type not the content because other protocol is used to get the content.
                Site.CaptureRequirementIfAreEqual<Type>(
                    typeof(_OLD_LARGE_INTEGER),
                    validationSamInfo.KickOffTime.GetType(),
                    "MS-PAC",
                    104388,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]KickOffTime:  A FILETIME structure that contains
                    LogoffTime minus the user account's forceLogoff attribute ([MS-ADA1] section 2.233) value.");

                bool isLogonCountValid = (validationSamInfo.LogonCount.GetType() == typeof(ushort))
                    && (validationSamInfo.LogonCount == expectedLogonCount);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104435,
                    actual LogonCount: {0},
                    expected LogonCount: {1}",
                    validationSamInfo.LogonCount,
                    expectedLogonCount);

                // Verify MS-NRPC requirement:  MS-NRPC_R104435.
                // The expectedLogonCount is the LogonCount attribute value.
                Site.CaptureRequirementIfIsTrue(
                    isLogonCountValid,
                    "MS-PAC",
                    104435,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]LogonCount: A 16-bit unsigned integer that contains
                    the user account's LogonCount attribute ([MS-ADA1] section 2.375) value.");

                bool isUserIdValid = (validationSamInfo.UserId.GetType() == typeof(uint))
                    && (validationSamInfo.UserId == DomainAdminRid);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104439,
                    actual UserId: {0},
                    expected AccountRid: {1}",
                    validationSamInfo.UserId,
                    DomainAdminRid);

                // Verify MS-NRPC requirement:  MS-NRPC_R104439.
                Site.CaptureRequirementIfIsTrue(
                    isUserIdValid,
                    "MS-PAC",
                    104439,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]UserId:  A 32-bit unsigned integer that contains
                    the RID of the account.");

                bool isPrimaryGroupRidValid = (validationSamInfo.PrimaryGroupId.GetType() == typeof(uint))
                    && (validationSamInfo.PrimaryGroupId == PrimaryGroupRid);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104441,
                    actual PrimaryGroupId: {0},
                    expected PrimaryGroupRid: {1}",
                    validationSamInfo.PrimaryGroupId,
                    PrimaryGroupRid);

                // Verify MS-NRPC requirement:  MS-NRPC_R104441.
                Site.CaptureRequirementIfIsTrue(
                    isPrimaryGroupRidValid,
                    "MS-PAC",
                    104441,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]PrimaryGroupId:  A 32-bit unsigned integer that
                    contains the RID for the primary group to which this account belongs.");

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

                // Verify MS-NRPC requirement:  MS-NRPC_R104442.
                Site.CaptureRequirementIfAreEqual<uint>(
                    validationSamInfo.GroupCount,
                    (uint)validationSamInfo.GroupIds.Length,
                    "MS-PAC",
                    104442,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]GroupCount: The number of groups in this list[
                    the list of GROUP_MEMBERSHIP (section 2.2.2) structures] MUST be equal to GroupCount.");

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

                // Verify MS-NRPC requirement:  MS-NRPC_R104443.
                Site.CaptureRequirementIfAreEqual<uint>(
                    validationSamInfo.GroupCount,
                    (uint)validationSamInfo.GroupIds.Length,
                    "MS-PAC",
                    104443,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]GroupIds:The number of groups in this list MUST
                    be equal to GroupCount.");

                // The value of set A to L bits.
                uint specifiedFlags = (uint)(0x00000001
                    | 0x00000002
                    | 0x00000008
                    | 0x00000020
                    | 0x00000040
                    | 0x00000080
                    | 0x00000100
                    | 0x00000200
                    | 0x00000400
                    | 0x00000800
                    | 0x00001000
                    | 0x00002000);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104445,
                    UserFlags: {0}",
                    validationSamInfo.UserFlags);

                uint allOtherFlagValue = validationSamInfo.UserFlags & (~specifiedFlags);

                // Verify MS-NRPC requirement:  MS-NRPC_R104445.
                Site.CaptureRequirementIfAreEqual<uint>(
                    0,
                    allOtherFlagValue,
                    "MS-PAC",
                    104445,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]UserFlags:All other bits[except the set of A to L
                    bits] MUST be set to zero");

                // Convert LogonDomainName value to string.
                string actualLogonDomainName = GetRpcUnicodeString(validationSamInfo.LogonDomainName);
                bool isLogonDomainNameValid = (validationSamInfo.LogonDomainName.GetType()
                                               == typeof(_RPC_UNICODE_STRING))
                    && actualLogonDomainName.Equals(primaryDomainNetBiosName, StringComparison.OrdinalIgnoreCase);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104448,
                    actual LogonDomainName: {0},
                    expected LogonDomainName: {1}",
                    actualLogonDomainName,
                    primaryDomainNetBiosName);

                // Verify MS-NRPC requirement:  MS-NRPC_R104448.
                Site.CaptureRequirementIfIsTrue(
                    isLogonDomainNameValid,
                    "MS-PAC",
                    104448,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]LogonDomainName:  A RPC_UNICODE_STRING structure
                    that contains the NetBIOS name of the domain to which this account belongs.");

                string actualSid = GetStringFromRpcSid(validationSamInfo.LogonDomainId[0]);

                // LogonDomainId array has only one element.
                bool isLogonDomainIdValid = (validationSamInfo.LogonDomainId.GetType() == typeof(_RPC_SID[]))
                    && actualSid.Equals(PrimaryDomainSID, StringComparison.OrdinalIgnoreCase);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104449,
                    actual LogonDomainId: {0},
                    expected LogonDomainId: {1}",
                    actualSid,
                    PrimaryDomainSID);

                // Verify MS-NRPC requirement:  MS-NRPC_R104449.
                Site.CaptureRequirementIfIsTrue(
                    isLogonDomainIdValid,
                    "MS-PAC",
                    104449,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]LogonDomainId:  A SID structure that contains the SID
                    for the domain specified in LogonDomainName.");

                // Initial the allSidCountInExtraSids to 0.
                int allSidCountInExtraSids = 0;

                // Get all sid count present in ExtraSids.
                for (int i = 0; i < validationSamInfo.ExtraSids.Length; i++)
                {
                    allSidCountInExtraSids += validationSamInfo.ExtraSids[i].Sid.Length;

                    // Verify Attributes member in NETLOGON_SID_AND_ATTRIBUTES structure.
                    this.VerifyAttributesInNetlogonSidAndAttributes(validationSamInfo.ExtraSids[i].Attributes, hresult);
                }

                bool isSidCountValid = (validationSamInfo.SidCount.GetType() == typeof(uint))
                    && (validationSamInfo.SidCount == (uint)allSidCountInExtraSids);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104450,
                    SidCount: {0},
                    allSidCount: {1}",
                    validationSamInfo.SidCount,
                    allSidCountInExtraSids);

                // Verify MS-NRPC requirement:  MS-NRPC_R104450.
                Site.CaptureRequirementIfIsTrue(
                    isSidCountValid,
                    "MS-PAC",
                    104450,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]SidCount:  A 32-bit unsigned integer that contains
                    the total number of SIDs present in the ExtraSids member.");

                // Get the actual logon server name value.
                string actualLogonServerValue = GetRpcUnicodeString(validationSamInfo.LogonServer);

                // Add the debug information.
                Site.Log.Add(
                    LogEntryKind.Debug,
                    @"Verify MS-NRPC_R104447,
                    actual LogonServer: {0},
                    expected LogonServer: {1}",
                    actualLogonServerValue,
                    Site.Properties["Common.WritableDC1.NetbiosName"]);

                bool isVerifyR104447 = (validationSamInfo.LogonServer.GetType() == typeof(_RPC_UNICODE_STRING))
                    && actualLogonServerValue.Equals(
                                                      Site.Properties["Common.WritableDC1.NetbiosName"],
                                                      StringComparison.OrdinalIgnoreCase);

                // Verify MS-NRPC requirement:  MS-NRPC_R104447.
                // KDC is PDC in our test environment.
                Site.CaptureRequirementIfIsTrue(
                    isVerifyR104447,
                    "MS-PAC",
                    104447,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure ]LogonServer:  A RPC_UNICODE_STRING structure that
                    contains the NetBIOS name of the Kerberos KDC that performed the authentication server (AS) ticket
                    request.");

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

                // Verify MS-NRPC requirement:  MS-NRPC_R104452.
                // _NETLOGON_SID_AND_ATTRIBUTES is corresponding to KERB_SID_AND_ATTRIBUTES,
                // It is only used to verify the type not the content.
                Site.CaptureRequirementIfAreEqual<Type>(
                    typeof(_NETLOGON_SID_AND_ATTRIBUTES[]),
                    validationSamInfo.ExtraSids.GetType(),
                    "MS-PAC",
                    104452,
                    @"[In NETLOGON_VALIDATION_SAM_INFO2 structure]ExtraSids:  A pointer to a list of
                    KERB_SID_AND_ATTRIBUTES (section 2.2.1) structures that contain a list of SIDs corresponding to
                    groups in domains other than the account domain to which the principal belongs.");
            }
        }