Bind() public method

Set up an RPC session with a specific server.
public Bind ( string serverName, Microsoft.Protocols.TestTools.StackSdk.Security.Sspi.AccountCredential credential, Microsoft.Protocols.TestTools.StackSdk.Security.Sspi.ClientSecurityContext securityContext ) : void
serverName string Server computer name
credential Microsoft.Protocols.TestTools.StackSdk.Security.Sspi.AccountCredential User account used to setup this session
securityContext Microsoft.Protocols.TestTools.StackSdk.Security.Sspi.ClientSecurityContext Security context of session
return void
コード例 #1
0
        protected SHARE_INFO_502_I GetShareInfo(string sharePath)
        {
            using (SrvsClient srvsClient = new SrvsClient(TestConfig.Timeout))
            {
                srvsClient.Bind(TestConfig.SutComputerName, TestConfig.AccountCredential, null);

                SHARE_INFO? shareInfo;
                uint retVal = srvsClient.NetrShareGetInfo(@"\\" + TestConfig.SutComputerName, sharePath, SHARE_ENUM_STRUCT_LEVEL.Level502, out shareInfo);
                if (retVal != 0 || shareInfo == null || shareInfo.Value.ShareInfo502 == null)
                {
                    BaseTestSite.Assert.Fail("Fail to get share info through MS-SRVS.");
                }
                srvsClient.UnBind();
                return shareInfo.Value.ShareInfo502.Value;
            }
        }
コード例 #2
0
 protected void SetShareInfo(string sharePath, SHARE_INFO_502_I shareInfo)
 {
     using (SrvsClient srvsClient = new SrvsClient(TestConfig.Timeout))
     {
         srvsClient.Bind(TestConfig.SutComputerName, TestConfig.AccountCredential, null);
         SHARE_INFO info = new SHARE_INFO { ShareInfo502 = shareInfo };
         uint? parmErr = 0;
         uint retVal = srvsClient.NetrShareSetInfo(@"\\" + TestConfig.SutComputerName, sharePath, SHARE_ENUM_STRUCT_LEVEL.Level502, info, ref parmErr);
         if (retVal != 0)
         {
             BaseTestSite.Assert.Fail("Fail to get share info through MS-SRVS.");
         }
         srvsClient.UnBind();
     }
 }
コード例 #3
0
        protected void SetShareInfo(string sharePath, SHARE_INFO_502_I shareInfo)
        {
            using (SrvsClient srvsClient = new SrvsClient(TestConfig.Timeout))
            {
                ClientSecurityContext securityContext =
                new SspiClientSecurityContext(
                    TestConfig.DefaultSecurityPackage,
                    TestConfig.AccountCredential,
                    Smb2Utility.GetCifsServicePrincipalName(TestConfig.SutComputerName),
                    ClientSecurityContextAttribute.Connection
                        | ClientSecurityContextAttribute.DceStyle
                        | ClientSecurityContextAttribute.Integrity
                        | ClientSecurityContextAttribute.ReplayDetect
                        | ClientSecurityContextAttribute.SequenceDetect
                        | ClientSecurityContextAttribute.UseSessionKey,
                    SecurityTargetDataRepresentation.SecurityNativeDrep);

                srvsClient.Bind(TestConfig.SutComputerName, TestConfig.AccountCredential, securityContext);
                SHARE_INFO info = new SHARE_INFO { ShareInfo502 = shareInfo };
                uint? parmErr = 0;
                uint retVal = srvsClient.NetrShareSetInfo(@"\\" + TestConfig.SutComputerName, sharePath, SHARE_ENUM_STRUCT_LEVEL.Level502, info, ref parmErr);
                if (retVal != 0)
                {
                    BaseTestSite.Assert.Fail("Fail to get share info through MS-SRVS.");
                }
                srvsClient.UnBind();
            }
        }