所以,我的问题与在生产服务器上的代码,运行Windows Server 2003 & IIS 6ASP.NET模拟不工作的生产
我试图模拟一个域帐户,它在本地工作正常。
虽然当它的功能模拟用户无法在服务器上,即返回false:
private bool impersonateValidUser(String userName, String domain, String password)
{
WindowsIdentity tempWindowsIdentity;
IntPtr token = IntPtr.Zero;
IntPtr tokenDuplicate = IntPtr.Zero;
if (RevertToSelf())
{
if (LogonUserA(userName, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref token) != 0)
{
if (DuplicateToken(token, 2, ref tokenDuplicate) != 0)
{
tempWindowsIdentity = new WindowsIdentity(tokenDuplicate);
impersonationContext = tempWindowsIdentity.Impersonate();
if (impersonationContext != null)
{
CloseHandle(token);
CloseHandle(tokenDuplicate);
return true;
}
}
}
}
if (token != IntPtr.Zero)
CloseHandle(token);
if (tokenDuplicate != IntPtr.Zero)
CloseHandle(tokenDuplicate);
return false;
}
注意,代码不会崩溃 - 它只是返回false。有没有人经历过这个,并有什么我应该开始看什么想法?我假设IIS配置在这里,但可能需要几周才能找到导致此问题的小问题。
我可以使用我试图模拟在服务器上安装驱动器的帐户,以便帐户用户/密码组合很好,并且可以用于在Windows资源管理器中进行身份验证。
请问哪个版本的IIS和Windows Server?请注意,您必须执行各种步骤才能进行委派,人们忘记做的最常见的事情就是允许服务器自己在Active Directory中委派“许可”。有关概览,请参阅http://support.microsoft.com/kb/810572。 – dash 2013-04-30 07:59:10
2003&IIS 6 - 很好,我也会加入到这个问题中。 – 2013-04-30 08:00:38
@dash该网站通常不会使用Windows模拟,因为它是外部面向的 - 但我使用它来执行一次身份验证,以从共享驱动器恢复文件。 – 2013-04-30 08:35:03