SharePoint 2010 and Office Web Apps: System.Data.SqlClient.SqlException: Cannot open database “WSS_Content” requested by the login. The login failed.

When trying to open a word document in Office Web Applications in a fresh install of SharePoint 2010 the word web application might just say that it could not open the document and something went wrong provided with a correlation ID.

The correlation ID gives the following stacktrace when checking the ULS log:

System.Data.SqlClient.SqlException: Cannot open database “WSS_Content” requested by the login. The login failed.  Login failed for user ‘DOMAIN\ACCOUNT’.
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
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.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, 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 Microsoft.SharePoint.Utilities.SqlSession.OpenConnection()

The solution is straightforward. The account mentioned does not have access to the content database, and this can be verified by checking the content database logins in SQL Management Studio. However, one should never touch SharePoint databases directly, so use the following PowerShell-script to grant content database permissions to the account:

Add-PSSnapin Microsoft.SharePoint.PowerShell

$webApp = Get-SPWebApplication “http://team.janmwk.steria.com”

$webApp.GrantAccessToProcessIdentity(“DOMAIN\ACCOUNT”)

When you try to open the word document in the word web application again, the error should now be gone and it should display the word document instead.

Leave a comment