2012-03-20 32 views
0

我試圖在服務器上部署網站。但它不起作用,說用戶沒有權限。我嘗試從Visual Studio在同一臺服務器上運行它,但沒有任何更改,它工作正常。我正在使用sql服務器身份驗證,我也將用戶設置爲dbowner。網站在Visual Studio上工作,但在IIS上不工作(用戶沒有授權)

這是錯誤消息我得到:

User does not have permission to perform this action. 
Description: An unhandled exception occurred during the execution of the current web  
request. Please review the stack trace for more information about the error and where 
it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: User does not have permission to  
perform this action. 

Source Error: 

An unhandled exception was generated during the execution of the current web request. 
Information regarding the origin and location of the exception can be identified using 
the exception stack trace below. 

Stack Trace: 
[SqlException (0x80131904): User does not have permission to perform this action.] 
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean 
breakConnection) +6333696 
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +412 
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, 
SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject 
stateObj) +1363 
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +53 
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, 
String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, 
SqlConnectionString connectionOptions, TimeoutTimer timeout) +6348638 
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection 
owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String 
newPassword, Boolean redirectedUserInstance) +6348553 
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, 
SqlConnectionString connectionOptions, Object providerInfo, String newPassword, 
SqlConnection owningObject, Boolean redirectedUserInstance) +352 
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 
options, 
Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) 
+506 
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection 
owningConnection, DbConnectionPool pool, DbConnectionOptions options) +49 
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) 
+6350358 
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) 
+78 
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 
+1938 
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection 
owningConnection) +89 
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection 
outerConnection, 
DbConnectionFactory connectionFactory) +6353246 
System.Data.SqlClient.SqlConnection.Open() +300 
System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean 
revertImpersonate) +150 
System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, 
Boolean 
revertImpersonation) +4712943 
System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, 
Boolean 
updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, 
String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& 
failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, 
DateTime& 
lastActivityDate) +3729431 
System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String 
password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, 
Int32& passwordFormat) +189 
System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String 
password) 
+202 

System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(
AuthenticateEventArgs e) +225 
System.Web.UI.WebControls.Login.AttemptLogin() +166 
System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +93 
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +52 
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean  
includeStagesAfterAsyncPoint) +3707 

我怎樣才能解決呢?

+0

這是問題的答案。 [鏈接] [1] [1]:http://stackoverflow.com/questions/8650212/give-aspnetdb-mdf-sql-db-iis-iusrs-permissions – Sas 2012-03-20 16:36:53

回答

1

錯誤是數據庫權限錯誤。您是否在Web服務器指向的SQL Server上設置了適當的權限?另外,如果連接字符串位於web.config文件中,請確保它不指向本地數據庫實例。

+0

我改變在web.config文件到服務器數據庫實例。我也給用戶作爲dbowner permision。我還有另一個ASPNETDB.MDF它維護用戶角色。我在使用Visual Studio部署網站的服務器上運行該網站,並且它工作正常。 – Sas 2012-03-20 14:39:50

+0

對不起,如果您的原始問題現在已解決,我無法從您的評論中得知它是否按預期工作? – javram 2012-03-20 14:42:50

+0

不,它沒有工作,我試圖詳細解釋這個問題,根據你在答案中提出的問題。 – Sas 2012-03-20 15:06:08

相關問題