基本的には、ログインしているユーザーを偽装してWebアプリケーションからネットワーク共有リソースにアクセスしようとしています。私はこの例に従った[http://msdn.microsoft.com/en-us/library/ms998351.aspx#paght000023_impersonatingbyusingwindowsidentity]、ここでは、キャストが失敗したことについてのライターは言及していません。私がそのキャストをしたとき、キャストできないというランタイム例外が発生しました。誰もが以前にこのような問題を経験しましたか?WindowsIdentity winId =(WindowsIdentity)HttpContext.Current.User.Identity;このキャスト作品を作る方法現在は失敗しています
ガイダンスやご意見は高く評価されています。
は、私はあなたはそれが するのは難しいので偽装して何をしようとしてわからない
WindowsIdentity winId = (WindowsIdentity)HttpContext.Current.User.Identity;
WindowsImpersonationContext ctx = null;
try
{
// Start impersonating
ctx = winId.Impersonate();
// Now impersonating
// Access resources using the identity of the authenticated user
}
// Prevent exceptions from propagating
catch
{
}
finally
{
// Revert impersonation
if (ctx != null)
ctx.Undo();
}
// Back to running under the default ASP.NET process identity
お読みください。このいずれかを参照してください。[http://msdn.microsoft.com/en-us/library/ms998351.aspx#paght000023_impersonatingbyusingwindowsidentity]、 – Shiva
キャストは常にi「が理由で失敗します言及した。 –