具有数据库的Web服务:SqlException
|
我写了一个可与SQL Server \ '08数据库一起使用的Web服务
当我尝试调用Web方法时,得到以下信息:
System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\\ASP.NET v4.0'.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
at System.Data.Linq.SqlClient.SqlProvider.get_IsSqlCe()
at System.Data.Linq.SqlClient.SqlProvider.InitializeProviderMode()
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at route.Logic..ctor() in C:\\Users\\Ilya\\Documents\\Visual Studio 2010\\Projects\\MobitourLibrary\\route\\Logic.cs:line 20
at Service..ctor() in c:\\inetpub\\wwwroot\\RouteGen\\App_Code\\Service.cs:line 14
问题出在哪里?
其他使用相同数据库的Win窗体应用程序可以正常工作,为什么WS不能?
没有找到相关结果
已邀请:
3 个回复
扇献隙
填盖
已为您的问题提供了详细的答案。这是我的两分钱。 如果您的环境中有Active Directory域设置,建议不要在连接中包括
和
。相反,我建议以下内容: 创建一个域帐户“ѭ4”,其中MyDomain将是活动目录域,而webservice将是该域中的Windows用户帐户。在“ 5”中,为该新的域帐户用户提供访问数据库的适当权限。 在ѭ6中,将应用程序池更改为在该服务帐户下运行。如果您运行的是IIS 7.5,则可以执行以下步骤: 在
中,展开
节点,然后单击
。 最好创建一个新的“ 10”,以免干扰其他可能使用应用程序池“ 11”的应用程序的功能。 创建与ASP.NET v4.0应用程序池类似的新应用程序池(例如
),不同之处在于新应用程序池将使用新创建的域帐户ѭ4the的标识而不是通常的ApplicationPoolIdentity。 在将Web服务部署到的虚拟目录/站点的“ 14”选项上,更改“应用程序池”属性以使用新创建的应用程序池“ 12”。 我相信此设置更加安全,并且可以避免在连接字符串中对用户ID和密码进行硬编码。 希望能有所帮助。
妒垮
)没有那里的权限。 不知道任何其他详细信息,我假设这是IIS中托管的ASP.NET Web应用程序/ Web服务,并且您很可能具有到已打开ѭ17has设置的数据库的连接字符串-因此,当前用户(这是IIS apppool用户)尝试连接到数据库-不能。 因此,更改您的连接字符串(请参阅http://www.connectionstrings.com上的许多示例)以指定可以连接的特定数据库用户: