は、私は以下の例を使用するが、私はまだ例外持っている:技術サポート個人的のためのサーバーパスにファイルを書き込むための偽装に関するユーザー権限は何ですか?
System.Security.Permissions.SecurityPermission ここでは、以下に提示された診断情報:システム」タイプの許可を リクエストを。 Security.Permissions.SecurityPermission、mscorlib
管理者は、ユーザーの資格情報を読み書きする完全な権限を有することを特徴とする
IntPtr userToken = IntPtr.Zero;
bool success = External.LogonUser(
"userID",
"domain.com",
"MyPassword",
(int) AdvApi32Utility.LogonType.LOGON32_LOGON_INTERACTIVE, //2
(int) AdvApi32Utility.LogonProvider.LOGON32_PROVIDER_DEFAULT, //0
out userToken);
if (!success)
{
throw new SecurityException("Logon user failed");
}
using (WindowsIdentity.Impersonate(userToken))
{
//Create a new GUID, extract the extension and create a new unique filename
string strFileGUID = System.Guid.NewGuid().ToString();
string extension = Path.GetExtension(attachment.AttachmentFileName);
string tempfilename = strFileGUID + extension;
string path = "ServerPath";
//Open a filestream and write the contents of the file at server path
FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write);
fs.Write(fileContent.Content, 0, fileContent.Content.Length);
fs.Flush();
fs.Close();
}
私はこの問題に悩まされているので、助けてもらえますか?
まず、 'System.Security.Permissions.SecurityPermission'は例外ではないクラスです。あなたが見ることができるすべての例外情報を追加できますか?内部例外、スタックトレース、および行番号はすべて役立ちます。 –
以下は、技術サポート担当者の診断情報です。 'System.Security.Permissions.SecurityPermission、mscorlib、Version = 2.0.0.0、Culture = neutral、PublicKeyToken = b77a5c561934e089'タイプのアクセス許可のリクエストに失敗しました。 VirusScanningPOC.VirusScan.Button3_Click(Object sender、EventArgs e) –
ありがとうございますが、これは私たちが必要とする情報をあまり提供していません。例外が発生したときにスクリーンショットを投稿できますか? –