リモート コンピューターに MSI パッケージをインストールしたいと考えています。ローカル コンピューターとリモート コンピューターはどちらも「adn.lan」というドメインのメンバーであり、接続にパラメーターとして渡すユーザー/パスワードには、リモート コンピューターへのフル アクセスがあります。connection.Authority を「ntdlmdomain:adran.lan」に設定すると、戻りパラメーターに「無効なパラメーター」が表示され、そのままにしてコメントどおりnull
にすると、connect()
正常に接続されますが、パッケージをインストールしようとすると戻りパラメーターが表示されます宛先のパッケージにアクセスできないこと。
これが私が試したコードです。
ConnectionOptions connection = new ConnectionOptions();
//connection.Authority = "ntdlmdomain:adn.lan"; // "kerberos:" + domain + @"\" + machine;
connection.Username = username;
connection.Password = password;
//connection.Impersonation = ImpersonationLevel.Identify ;
connection.Authentication = AuthenticationLevel.Packet;
ManagementScope scope = new ManagementScope("\\\\RemoteMachineName\\root\\CIMV2", connection);
scope.Connect();
ManagementPath p = new ManagementPath("Win32_Product");
ManagementClass classInstance = new ManagementClass(scope, p, null);
ManagementBaseObject inParams = classInstance.GetMethodParameters("Install");
inParams["AllUsers"] = true;
inParams["Options"] = string.Empty;
inParams["PackageLocation"] = "\\\\LocalMachineName\\Share\\Prescription.msi";
ManagementBaseObject outParams = classInstance.InvokeMethod("Install", inParams, null);
string retVal = outParams["ReturnValue"].ToString();
Identityに設定theconnection.Impersonation
すると、結果は「アクセスが拒否されました」になります。