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; } }
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(); } }
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(); } }