这是我一直在尝试做的
使用表单身份验证和活动目录成员身份构建 ASP.NET MVC 3 应用程序。Web 服务器和数据库是不同的物理服务器,因此是双跳。
我认为答案是这篇关于约束委派和协议转换的旧文章?到目前为止,我还不能让这项技术发挥作用。
在部署到生产设置中的 Windows 2008 (IIS7) 之前,我正在从我的 DEV 机器(Windows 7、IIS7)上测试这个 Web 服务器。Windows 2008 会有所作为吗?
什么有效,什么失败
我可以使用表单身份验证和 AD 成员身份登录。这似乎工作正常。当我尝试使用此代码进行数据库调用时:
public void AsUser(Action action)
{
using (var id = new WindowsIdentity(User.Identity.Name + @"@example.com"))
{
WindowsImpersonationContext context = null;
try
{
context = id.Impersonate();
action.Invoke();
}
catch (Exception ex)
{
// ex.Message is The type initializer for System.Data.SqlClient.SqlConnection threw an exception
// buried inner exeption is Requested registry access is not allowed
}
finally
{
if (context != null)
{
context.Undo();
}
}
}
}
它失败并出现异常,导致我相信我在本地 DEV 服务器上存在设置问题。内部例外是Requested registry access is not allowed
.
如果我设置断点并WindowsIdentity
在调用后检查,Impersonate()
我会看到ImpersonationLevel
设置为Identification
. 这似乎是它设置不正确的线索。任何人都可以确认吗?
我在正确的轨道上吗?这甚至可以设置吗? 任何指针将不胜感激。