我有一个需要Windows集成安全性的ASP.NET应用程序。由于某种原因,我不知道在这里讨论什么,我需要在运行时创建一个WebRequest,调用应用程序中的其他页面并处理结果。
这个应用程序运行在我们使用DNS别名的服务器上,比如theapp.domain.com。
因此,我创建了一个具有预定义的域用户和密码的NetworkCredential,并将其附加到请求中。
这是我得到的:
[Win32Exception (0x80004005): The logon attempt failed]
System.Net.NTAuthentication.GetOutgoingBlob(Byte[] incomingBlob, Boolean throwOnError, SecurityStatus& statusCode) +1404402
System.Net.NTAuthentication.GetOutgoingBlob(String incomingBlob) +78
System.Net.NegotiateClient.DoAuthenticate(String challenge, WebRequest webRequest, ICredentials credentials, Boolean preAuthenticate) +560
System.Net.NegotiateClient.Authenticate(String challenge, WebRequest webRequest, ICredentials credentials) +14
System.Net.AuthenticationManager.Authenticate(String challenge, WebRequest request, ICredentials credentials) +247
System.Net.AuthenticationState.AttemptAuthenticate(HttpWebRequest httpWebRequest, ICredentials authInfo) +243
System.Net.HttpWebRequest.CheckResubmitForAuth() +232
System.Net.HttpWebRequest.CheckResubmit(Exception& e) +5299747
[WebException: The remote server returned an error: (401) Unauthorized.]
System.Net.HttpWebRequest.GetResponse() +5313085
Entropy.Envoy.Web.Corporate.ExportFilter.GetTargetReportContent(Uri targetUrl, HttpCookieCollection cookies) +521
Entropy.Envoy.Web.Corporate.ExportFilter.Page_Load(Object sender, EventArgs e) +139
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627不过,相同的代码可以在其他具有类似设置的服务器上运行。怎么一回事?
发布于 2009-11-04 07:29:48
找到了这个问题的答案事实证明,将SPN添加到Active Directory就像添加SPN一样简单:
setspn -a HTTP//WebServer.domain.com customDomainAccount
setspn -a HTTP//servername customDomainAccounthttps://stackoverflow.com/questions/1618507
复制相似问题