当前位置: 首页>>代码示例>>C#>>正文


C# Smb2FunctionalClient.ValidateNegotiateInfo方法代码示例

本文整理汇总了C#中Smb2FunctionalClient.ValidateNegotiateInfo方法的典型用法代码示例。如果您正苦于以下问题:C# Smb2FunctionalClient.ValidateNegotiateInfo方法的具体用法?C# Smb2FunctionalClient.ValidateNegotiateInfo怎么用?C# Smb2FunctionalClient.ValidateNegotiateInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Smb2FunctionalClient的用法示例。


在下文中一共展示了Smb2FunctionalClient.ValidateNegotiateInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestValidateNegotiateInfo

        private void TestValidateNegotiateInfo(Smb2FunctionalClient client, ValidateNegotiateInfoRequestType requestType, DialectRevision[] invalidDialects = null)
        {
            #region Check Applicability
            TestConfig.CheckDialect(DialectRevision.Smb30);
            TestConfig.CheckIOCTL(CtlCode_Values.FSCTL_VALIDATE_NEGOTIATE_INFO);
            TestConfig.CheckDialectIOCTLCompatibility(CtlCode_Values.FSCTL_VALIDATE_NEGOTIATE_INFO);
            // Server will terminate connection if Validate Negotiate Info Request is not signed.
            TestConfig.CheckSigning();
            #endregion

            BaseTestSite.Log.Add(LogEntryKind.TestStep, "Start a client by sending the following requests: NEGOTIATE;  SESSION_SETUP; TREE_CONNECT");

            Guid clientGuid = Guid.NewGuid();
            DialectRevision[] requestDialects = TestConfig.RequestDialects;
            Capabilities_Values clientCapabilities = Capabilities_Values.GLOBAL_CAP_DFS | Capabilities_Values.GLOBAL_CAP_DIRECTORY_LEASING | Capabilities_Values.GLOBAL_CAP_LARGE_MTU | Capabilities_Values.GLOBAL_CAP_LEASING | Capabilities_Values.GLOBAL_CAP_MULTI_CHANNEL | Capabilities_Values.GLOBAL_CAP_PERSISTENT_HANDLES;
            SecurityMode_Values clientSecurityMode = SecurityMode_Values.NEGOTIATE_SIGNING_ENABLED;
            NEGOTIATE_Response? negotiateResponse = null;
            status = client.Negotiate(
                requestDialects,
                TestConfig.IsSMB1NegotiateEnabled,
                clientSecurityMode,
                clientCapabilities,
                clientGuid,
                (Packet_Header header, NEGOTIATE_Response response) =>
                {
                    BaseTestSite.Assert.AreEqual(
                        Smb2Status.STATUS_SUCCESS,
                        header.Status,
                        "Negotiation should succeed, actually server returns {0}.", Smb2Status.GetStatusCode(header.Status));

                    TestConfig.CheckNegotiateDialect(DialectRevision.Smb30, response);

                    negotiateResponse = response;
                });

            status = client.SessionSetup(
                TestConfig.DefaultSecurityPackage,
                TestConfig.SutComputerName,
                TestConfig.AccountCredential,
                TestConfig.UseServerGssToken);

            uint treeId;
            string ipcPath = Smb2Utility.GetIPCPath(TestConfig.SutComputerName);
            status = client.TreeConnect(ipcPath, out treeId);

            VALIDATE_NEGOTIATE_INFO_Request validateNegotiateInfoReq;
            switch (requestType)
            {
                case ValidateNegotiateInfoRequestType.None:
                case ValidateNegotiateInfoRequestType.InvalidMaxOutputResponse:
                    validateNegotiateInfoReq.Guid = clientGuid;
                    validateNegotiateInfoReq.Capabilities = clientCapabilities;
                    validateNegotiateInfoReq.SecurityMode = clientSecurityMode;
                    validateNegotiateInfoReq.DialectCount = (ushort)requestDialects.Length;
                    validateNegotiateInfoReq.Dialects = requestDialects;
                    break;

                case ValidateNegotiateInfoRequestType.InvalidDialects:
                    validateNegotiateInfoReq.Guid = clientGuid;
                    validateNegotiateInfoReq.Capabilities = clientCapabilities;
                    validateNegotiateInfoReq.SecurityMode = clientSecurityMode;
                    validateNegotiateInfoReq.DialectCount = (ushort)invalidDialects.Length;
                    validateNegotiateInfoReq.Dialects = invalidDialects;
                    break;

                case ValidateNegotiateInfoRequestType.InvalidGuid:
                    validateNegotiateInfoReq.Guid = Guid.NewGuid();
                    validateNegotiateInfoReq.Capabilities = clientCapabilities;
                    validateNegotiateInfoReq.SecurityMode = clientSecurityMode;
                    validateNegotiateInfoReq.DialectCount = (ushort)requestDialects.Length;
                    validateNegotiateInfoReq.Dialects = requestDialects;
                    break;

                case ValidateNegotiateInfoRequestType.InvalidSecurityMode:
                    validateNegotiateInfoReq.Guid = clientGuid;
                    validateNegotiateInfoReq.Capabilities = clientCapabilities;
                    validateNegotiateInfoReq.SecurityMode = SecurityMode_Values.NONE;
                    validateNegotiateInfoReq.DialectCount = (ushort)requestDialects.Length;
                    validateNegotiateInfoReq.Dialects = requestDialects;
                    break;

                case ValidateNegotiateInfoRequestType.InvalidCapabilities:
                    validateNegotiateInfoReq.Guid = clientGuid;
                    validateNegotiateInfoReq.Capabilities = Capabilities_Values.NONE;
                    validateNegotiateInfoReq.SecurityMode = clientSecurityMode;
                    validateNegotiateInfoReq.DialectCount = (ushort)requestDialects.Length;
                    validateNegotiateInfoReq.Dialects = requestDialects;
                    break;

                default:
                    throw new InvalidOperationException("Unexpected ValidateNegotiateInfo request type " + requestType);
            }

            byte[] inputBuffer = TypeMarshal.ToBytes<VALIDATE_NEGOTIATE_INFO_Request>(validateNegotiateInfoReq);
            byte[] outputBuffer;
            VALIDATE_NEGOTIATE_INFO_Response validateNegotiateInfoResp;
            BaseTestSite.Log.Add(
                LogEntryKind.TestStep,
                "Attempt to validate negotiate info with info Guid: {0}, Capabilities: {1}, SecurityMode: {2}, DialectCount: {3}, Dialects: {4}",
                validateNegotiateInfoReq.Guid, validateNegotiateInfoReq.Capabilities, validateNegotiateInfoReq.SecurityMode, validateNegotiateInfoReq.DialectCount, Smb2Utility.GetArrayString(validateNegotiateInfoReq.Dialects));
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:WindowsProtocolTestSuites,代码行数:101,代码来源:ValidateNegotiateInfo.cs


注:本文中的Smb2FunctionalClient.ValidateNegotiateInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。