0

NT1 と NT2 というドメインが必要です。

Exchange サーバー (ドメイン NT2) で Powershell コマンドレットを呼び出す C# アプリケーションがあります。NT2\Userの資格情報を使用します。

抜粋:

using System.Management.Automation;
using System.Management.Automation.Runspaces;
...
var connectionInfo = nw WSManConnectionInfo(
    exchangeUri,
    "http://schemas.microsoft.com/powershell/Microsoft.Exchange",
    new PSCredential(nt2User, password));
connectionInfo.SkipRevocationCheck = true;
connectionInfo.SkipCACheck = true;
connectionInfo.SkipCNCheck = true;

using var runspace = RunspaceFactory.CreateRunspace(connectionInfo);
runspace.Open();
using var pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript("Set-User -Identity Contoso\Jill -DisplayName Jill");
pipeline.Invoke();

このアプリケーションを自分のコンピューター (ドメイン NT1) で実行するだけで問題ありません。

アプリケーションがドメイン NT1 のサーバーに展開され、IIS でホストされると、動作を停止します。IIS アプリケーション プールは、ドメイン NT1 ( NT1\User ) の ID で構成されます。

System.Managemnt.Automation.RemoteRunspace.Open() で System.Management.Automation.Remoting.PSRemotingTransportException をスローします。

Connecting to remote server mail.test.brightfulsolutions.com failed with the following error message: Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.

IIS アプリケーション プール ID ユーザー NT1\User と Powershell 意図したユーザー NT2\User の競合のようですが、どうすればよいかわかりません。

提案 (コード、サーバー構成) は大歓迎です。

4

0 に答える 0