IIS 7 内の asp.mvc アプリでいくつかのコードを実行しています。このコードは、ファイルを UNC 共有に保存することになっています。この関数は、filePathname = "\MYSRV\sites\docs\10080003\egg.txt' を使用して、一部のコントローラー コードから呼び出されます。
public void EnsureDocument(string filePathName ,string content,WindowsIdentity identity )
{
System.Security.Principal.WindowsImpersonationContext impersonationContext = null;
try
{
impersonationContext = ((System.Security.Principal.WindowsIdentity)identity).Impersonate();
File.WriteAllText(filePathName, content);
}
finally
{
impersonationContext.Undo();
}
}
asp.net mvc コントローラーからの呼び出しは次のようになります...
// pass running identity
documentSvc.EnsureDocument(filePathname, content, WindowsIdentity.GetCurrent());
//documentSvc.EnsureCaseDocument(filePathname,content,System.Security.Principal.WindowsIdentity)User.Identity);
NUnit テストからの呼び出しは次のようになります...
documentSvc.EnsureDocument(filePathname, content, WindowsIdentity.GetCurrent() );
症状は、NUnit コードがファイルをドロップすることですが、asp.net mvc からの呼び出しはファイルをドロップしません。
**テスト 1 : PASSES、DROPS FILE ** Nunit コードは ID { AuthType=Keberos, ImpersonationLevel=none , Name="DOMAIN\Fred Blogs" } を介して送信し、これにより unc にファイルがドロップされます。
**テスト 2: 失敗、ファイルをドロップしない ** web.config で impersonate="true" を指定し、呼び出しを行う
documentSvc.EnsureDocument(filePathname, content, WindowsIdentity.GetCurrent());
asp.net mvc コードは { AuthType=Keberos, ImpersonationLevel=Delegation, Name="DOMAIN\Fred Blogs" } を介して送信し、ファイルは削除されません。
**テスト 3: 失敗、ファイルをドロップしない ** web.config で impersonate="true" を使用せず、呼び出しと呼び出しを行う
documentSvc.EnsureCaseDocument(filePathname,content,System.Security.Principal.WindowsIdentity)User.Identity);
asp.net mvc コードは { AuthType=Negotiate, ImpersonationLevel=Delegation, Name="DOMAIN\Fred Blogs" } を介して送信し、ファイルは削除されません。
?