2
我们有一个ashx http处理程序,用于在ProcessRequest期间从ServerVariables检索REMOTE_USER变量。检索REMOTE_USER服务器变量时出现异常
public void ProcessRequest(HttpContext context)
{
if (context.Request.ServerVariables["REMOTE_USER"].Contains("\\")) // exception is thrown here
...
身份验证由IIS使用基本身份验证(域控制器上的Windows帐户)处理。
对于一些用户来说,这开始出现问题,并抛出以下异常(工作正常了几个小时后):我们重新启动该应用程序的问题一天左右解决的应用程序池后
[IdentityNotMappedException: Some or all identity references could not be translated.]
System.Security.Principal.SecurityIdentifier.Translate(IdentityReferenceCollection sourceSids, Type targetType, Boolean forceSuccess) +7608560
System.Security.Principal.SecurityIdentifier.Translate(Type targetType) +100
System.Security.Principal.WindowsIdentity.GetName() +164
System.Security.Principal.WindowsIdentity.get_Name() +31
System.Web.HttpRequest.CalcDynamicServerVariable(DynamicServerVariable var) +8726378
System.Web.HttpServerVarsCollection.GetSimpleServerVar(String name) +424
System.Web.HttpServerVarsCollection.Get(String name) +8634072
System.Collections.Specialized.NameValueCollection.get_Item(String name) +7
Some.Namespace.AHttpHandler.ProcessRequest(HttpContext context) in c:\afolder\AHttpHandler.ashx.cs:34
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +181
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
。
任何想法? 我们应该使用另一个服务器变量来检索用户名吗?
谢谢!
'身份验证是由IIS使用基本身份验证来处理的吗?但基本认证是通过HTTP头传递用户名密码。你的意思是'windows身份验证'? – Aliostad 2011-03-04 13:19:15
是的,这是基本身份验证,它使用Active Directory中的用户:Windows身份。 – 2011-03-04 13:37:22