【发布时间】:2012-01-30 08:04:15
【问题描述】:
我对在活动目录环境中进行开发还很陌生。所以请多多包涵……
[A] 我一直在运行 fiddler 浏览我网站上的一些页面,我注意到以下内容。
[B] 据我了解,401 错误是由 NTLM 的工作原理引起的。
[C] 但我也支持代理,所以我也会收到这些响应
我还注意到 fiddler 中的 auth 选项卡结合了这些结果
代理结果。 [C]
存在代理验证标头:协商
存在代理验证标头:Kerberos
存在代理验证标头:NTLM
不存在 WWW-Authenticate 标头。
401.2 结果 [B]
没有 Proxy-Authenticate Header 存在。
存在WWW-Authenticate Header:协商
存在WWW-Authenticate Header:NTLM
注意:在我的控制器中,我有一个继承自 AuthorizeAttribute 类的自定义 Authorize 属性。
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
if (base.AuthorizeCore(httpContext))
{
/* Return true immediately if the authorization is not
locked down to any particular AD group */
if (Groups == null)
return true;
//admin user -> allow all actions
if (IsUserInRole("Admin"))
{
return true;
}
else
//Domain_Users -> continue for division level permissions
if (IsUserInRole("Production_Users") || IsUserInRole("Engineering_Users") || IsUserInRole("Quality_Users"))
{
//if we've gotten here, the user is a domain user & in a specific division,
//depending on the view we're dealing with, and the users permissions allow/deny
switch (httpContext.ApplicationInstance.Request.RequestContext.RouteData.Values["action"].ToString())
{
case "Add":
return HttpContext.Current.User.IsInRole(GetGroupFromAppConfig("AddAllow"));
case "Edit":
return HttpContext.Current.User.IsInRole(GetGroupFromAppConfig("EditAllow"));
case "Delete":
return HttpContext.Current.User.IsInRole(GetGroupFromAppConfig("Deletellow"));
default:
//default = no action type is specified => we're dealing with a "view"
//& as the user has division level permissions, allow.
return true;
}
}
else
{
return false;
}
}
return false;
}
现在我的问题...是否可以减少一些 401 结果和代理结果,因为它们似乎会导致性能问题。
还有,
是否可以对 401 和代理结果应用 gzip/deflate 压缩以减小它们的大小?
【问题讨论】:
-
对于服务器授权问题,请考虑使用 web.config 中的位置标签公开文件位置
标签: asp.net-mvc asp.net-mvc-3 iis active-directory iis-7.5