以下の例を使用しましたが、まだ例外があります:
System.Security.Permissions.SecurityPermission テクニカル サポート担当者向けの診断情報を以下に示します。
管理者は、ユーザー資格情報には読み取りと書き込みの完全なアクセス許可があると述べました
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();
}
この問題に行き詰まっているので、助けてもらえますか?