単独で作業している C# から SSIS パッケージを実行しようとしています。私が抱えている問題は、パッケージのユーザーをオンザフライで設定したいということです。機能しているように見える偽装クラスをセットアップしましたが、IIS から実行するとパッケージがエラーをスローします。ただし、VS2010 デバッグから実行すると機能します。
using (ImpersonatedUser iu = new ImpersonatedUser("username", "domain", "password"))
{
Application app = new Application();
Package package = null;
MyEventListener eventListener = new MyEventListener();
app.PackagePassword = "packagepassword";
package = app.LoadPackage(@"packagepath", null);
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute(null, null, eventListener, null, null);
if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
{
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
{
lblErrorOutput.Text += "<br />Package Execution results: " + local_DtsError.Description.ToString();
lblErrorOutput.Text += eventListener.output;
}
}
else
{
lblErrorOutput.Text = WindowsIdentity.GetCurrent().Name;
lblErrorOutput.Text += eventListener.output;
}
}
これは、デバッグから実行したときの出力と、IIS (同じコンピューター上) から実行したときの出力です。
domain\user
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Validation phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Validation phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Prepare for Execute phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Pre-Execute phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/Source File [1] : The processing of file "filepathandname.csv" has started.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Validation phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Prepare for Execute phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Pre-Execute phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/Flat File Destination [16] : The processing of file "filepathandname.csv" has started.
その後、IIS を介して
domain\user
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Validation phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Validation phase is beginning.
Error in: Microsoft.SqlServer.Dts.Runtime.Package/Connection manager "SourceConnectionFlatFile" : The file name property is not valid. The file name is a device or contains invalid characters.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Prepare for Execute phase is beginning.
Error in: Microsoft.SqlServer.Dts.Runtime.Package/Connection manager "SourceConnectionFlatFile" : The file name property is not valid. The file name is a device or contains invalid characters.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Pre-Execute phase is beginning.
Error in: Microsoft.SqlServer.Dts.Runtime.Package/Connection manager "SourceConnectionFlatFile" : The file name property is not valid. The file name is a device or contains invalid characters.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline : Execute phase is beginning.
Information: Microsoft.SqlServer.Dts.Runtime.TaskHost/Destination - : The final commit for the data insertion in "component "Destination" (94)" has started.
Error in: Microsoft.SqlServer.Dts.Runtime.TaskHost/File System Task : An error occurred with the following error message: "Could not find file 'filepathandname.csv'.".
私が目にするものはすべて、そのアクセス許可に基づいており、パッケージを実行しているユーザーはファイルにアクセスできないと信じさせてくれます。デバッグを実行すると、コンピューターにログインしたときに実行されますが、IIS を実行すると、DefaultAppPool が実行されます。
「lblErrorOutput.Text = WindowsIdentity.GetCurrent().Name;」を追加したチェック 私が期待するユーザーを私に見せています。何が起こっているのかよくわかりません。パッケージの実行は偽装されたユーザーを無視していますか? もしそうなら、どうすればそれを手に入れることができますか。
ありがとう