更改web.config
后,出现以下错误。
更改前:
<connectionStrings>
<add name="CS1"
connectionString="Server=S1; Database=DB1; User ID=Admin; Password=AdminPW; Persist Security Info=True; Max Pool Size=200; Connection Timeout=60" />
</connectionStrings>
更改后:
<connectionStrings>
<add name="CS1"
connectionString="Data Source=S1; Initial Catalog=DB1; Integrated Security=True;"
providerName="System.Data.SqlClient" />
</connectionStrings>
错误:
用户'NT AUTHORITY \ ANONYMOUS LOGON'登录失败。
说明:执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪,以获取有关错误及其在代码中起源的更多信息。异常详细信息:System.Data.SqlClient.SqlException:用户'NT AUTHORITY \ ANONYMOUS LOGON'登录失败。
堆栈跟踪:
[SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.]
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager) +1431
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) +1085
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) +70
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +964
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection) +109
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) +1529
System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) +156
System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) +258
System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) +312
System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) +202
System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) +413
System.Data.SqlClient.SqlConnection.Open() +128
MROWebPartCollection.BLL.Common.DataProvider.ConnectionDB() +263
MROWebPartCollection.BLL.Provider.MROQ_TBL_USER_PROFILEProvider..ctor() +245
MROWebPartCollection.ProductWP.CoaCoc.CoaCocUserControl..ctor() +125
ASP._controltemplates_mrowebpartcollection_productwp_coacoc_coacocusercontrol_ascx..ctor() +16
__ASP.FastObjectFactory_app_web_coacocusercontrol_ascx_16352c62_o2rjt3li.Create_ASP__controltemplates_mrowebpartcollection_productwp_coacoc_coacocusercontrol_ascx() +31
System.Web.UI.TemplateControl.LoadControl(IWebObjectFactory objectFactory, VirtualPath virtualPath, Type t, Object[] parameters) +282
System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) +120
MROWebPartCollection.ProductWP.CoaCoc.CoaCoc.CreateChildControls() +96
System.Web.UI.Control.EnsureChildControls() +130
System.Web.UI.Control.PreRenderRecursiveInternal() +66
System.Web.UI.Control.PreRenderRecursiveInternal() +276
System.Web.UI.Control.PreRenderRecursiveInternal() +276
System.Web.UI.Control.PreRenderRecursiveInternal() +276
System.Web.UI.Control.PreRenderRecursiveInternal() +276
System.Web.UI.Control.PreRenderRecursiveInternal() +276
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6881
答案 0 :(得分:3)
如果您使用集成安全性,则必须授予应用程序池活动目录帐户访问SQL Server数据库的权限。这里有一些提示:
当然,这些步骤中的每一个步骤都有许多细节需要注意。
我还应注意,以上所有说明均假定您要使用标准登录名来设置数据库。另一方面,如果您要使用正在浏览站点的用户的Active Directory凭据向SQL Server进行身份验证,则将要使用IIS模拟而不是上面概述的步骤。 This article解释了假冒的基本知识。