When I debug to run the code as below, there is no errors or exception occurred. But the software that I choose isn't installed successfully on the target computer.
public ActionResult Index() { string url = "http://MyServer/CMApplicationCatalog/ApplicationViewService.asmx"; BasicHttpBinding binding = new BasicHttpBinding(); binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly; binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; ApplicationViewServiceSoapClient client = new ApplicationViewServiceSoapClient(binding, new EndpointAddress(url)); int total = 0; AppDetailView[] apps = client.GetApplications( ApplicationProperty.Name, null, ApplicationProperty.Name, "", 20, 0, true, ApplicationClassicDisplayName.PackageProgramName, false, null, out total); ViewBag.appLength = apps.Length; // New connection ConnectionOptions ops = new ConnectionOptions(); ops.Username = "TestUser01"; ops.Password = "12345678"; ops.Authority = "DOMAIN:sccm.cn"; ops.EnablePrivileges = true; string userIp = HttpContext.Request.UserHostAddress; string address = userIp; // New remote connection with client ManagementScope scope = new ManagementScope(@"\\" + address + @"\root\ccm\ClientSdk", ops); // call WMI ManagementClass cls = new ManagementClass(scope.Path.Path, "CCM_SoftwareCatalogUtilities", null); cls.Scope.Options = scope.Options; // Get DeviceId ManagementBaseObject outSiteParams = cls.InvokeMethod("GetDeviceId", null, null); // Display current site code. string clientId = outSiteParams["ClientId"].ToString(); string signedClientId = outSiteParams["SignedClientId"].ToString(); // Invoke InstallApplication Method InstallationInformation retInfo = client.InstallApplication(apps[0].ApplicationId, clientId + "," + signedClientId, null); ViewBag.installationInfo = retInfo.BodySignature; return View(); }
The applicationID and deviceID have already got from previous method and SDK, and the reserved has been set into null.
Is there any process needed which is ignored by me?
I am new to the SCCM development, this question confuse me a lot.
Thanks a lot for your ideas!