【发布时间】:2015-10-13 11:51:00
【问题描述】:
我的asp.net 4.0 Application 有一个奇怪的行为,因为我已经更新到 Windows10(我认为它带有 10)。
我有一个在 IIS 中使用 BasicAuthentication 的应用程序 - 在我的 Login.aspx 中,我手动 verifying user 和 password 针对定义的 AD 域。
如果凭据有效,我会在会话中存储一个带有一些用户数据的简单对象并重定向到我的主页。
到目前为止一切顺利 - 使用该应用程序,用户可以删除文件和目录。这些操作始终是当前用户的performed under 和impersonation context。
进入“模拟上下文”:(仅主要部分)
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public virtual void Enter(LogonType logonType = LogonType.LOGON32_LOGON_INTERACTIVE, LogonProvider provider = LogonProvider.LOGON32_PROVIDER_DEFAULT)
{
token = IntPtr.Zero;
//Create the token
bool logonSuccessfull = GetToken(this.username, this.password, this.domain, ref token, logonType, provider);
WindowsIdentity identity;
identity = new WindowsIdentity(token);
impContext = identity.Impersonate();
}
如果用户删除目录:
Public void Delete(string directory)
{
//1. Entering impersonation context before (context.Enter();)
//2. Delete the file (executing this basic .net method):
System.IO.Directory.Delete(directory, true);
//3. Leaving the impersonation context after (context.Leave() -> .Undo();)
}
在资源管理器中以管理员身份操作i can still see the directory(之前已关闭)。但如果我想打开文件夹,我会收到access denied 消息。我也是not able to 监视目录的权限或become the owner 这个“幽灵文件夹”。快速的文件系统检查也没有帮助。
但是:如果applicationpool ends - 文件夹消失了...
Applicationpool 是一个Classic .net 4.0 Pool 和Network-Identity(此时更改此设置并未解决问题)
有人知道为什么不立即删除它们吗? 以及如何强制?
【问题讨论】:
标签: .net iis-7.5 windows-10 delete-file impersonation