public override void Initialize(ITestSite testSite)
 {
     base.Initialize(testSite);
     this.site       = testSite;
     this.testConfig = new TestConfig(testSite);
     this.client     = null;
 }
 public SmbdAdapter(
     ITestSite testSite,
     SmbdLogEvent logNotifyCompletion = null)
 {
     this.Initialize(testSite);
     this.client = new Smb2OverSmbdTestClient(
         testConfig.Smb2ConnectionTimeout,
         testConfig.RdmaLayerLoggingEnabled ? logNotifyCompletion : null);
 }
Example #3
0
        public uint Smb2AlternativeChannelSessionSetup(
            Smb2OverSmbdTestClient mainChannelClient,
            string domainName,
            string userName,
            string password,
            string serverName,
            SESSION_SETUP_Request_SecurityMode_Values securityMode = SESSION_SETUP_Request_SecurityMode_Values.NEGOTIATE_SIGNING_ENABLED,
            SESSION_SETUP_Request_Capabilities_Values capabilities = SESSION_SETUP_Request_Capabilities_Values.GLOBAL_CAP_DFS,
            ushort creditRequest = 64)
        {
            sessionId  = mainChannelClient.sessionId;
            sessionKey = mainChannelClient.sessionKey;

            Smb2SetSessionSigningAndEncryption(true, false);

            Packet_Header          header;
            SESSION_SETUP_Response sessionSetupResponse;

            SspiClientSecurityContext sspiClientGss =
                new SspiClientSecurityContext(
                    SecurityPackageType.Negotiate,
                    new AccountCredential(domainName, userName, password),
                    Smb2Utility.GetCifsServicePrincipalName(serverName),
                    ClientSecurityContextAttribute.None,
                    SecurityTargetDataRepresentation.SecurityNativeDrep
                    );

            // Server GSS token is used only for Negotiate authentication
            sspiClientGss.Initialize(gssToken);


            uint status;

            do
            {
                status = SessionSetup(
                    1,
                    creditRequest,
                    Packet_Header_Flags_Values.FLAGS_SIGNED,
                    messageId,
                    sessionId,
                    SESSION_SETUP_Request_Flags.SESSION_FLAG_BINDING,
                    securityMode,
                    capabilities,
                    0,
                    sspiClientGss.Token,
                    out sessionId,
                    out gssToken,
                    out header,
                    out sessionSetupResponse
                    );

                CalculateSmb2AvailableCredits(1, packetHeader.CreditRequestResponse);

                if ((status == Smb2Status.STATUS_MORE_PROCESSING_REQUIRED || status == Smb2Status.STATUS_SUCCESS) &&
                    gssToken != null && gssToken.Length > 0)
                {
                    sspiClientGss.Initialize(gssToken);
                }
            } while (status == Smb2Status.STATUS_MORE_PROCESSING_REQUIRED);

            if (status == Smb2Status.STATUS_SUCCESS)
            {
                sessionKey = sspiClientGss.SessionKey;
                Smb2SetSessionSigningAndEncryption(true, false, true);
            }

            return(status);
        }