我用下面的例子,但我都还是有例外:
System.Security.Permissions.SecurityPermission 这里在下文中介绍的技术支持企业人事诊断信息:请求类型的权限“System.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();
}
你能帮帮我我坚持这个问题?