简体   繁体   中英

asp.net/sql server/iis permissions

I'm developing an ASP.NET web app that needs to access an SQL Server database. The server the app needs to run on is running Windows Server 2000, SQL server 2000, IIS6, and .NET 2.0.

If I run the web app on my machine with Visual Web Developer 2010 with the testing webserver in Visual studio, but accessing the database on the actual web server, it works fine. However, If I put this app on the actual webserver, and try to access it through the browser, I get a permissions errors saying I don't have access to those tables.

There are two tables my app needs to access. On one of them I changed the permissions with SQL Management Studio to allow the public group select permissions, and that solved the problem. On the other table (very large table) I tried to do the same, but got an error saying it timed out waiting to get a lock on the table. Is there a way to change this timeout or another way to change the permissions?

I don't believe I should even have to change the permissions though, because there are classic ASP apps on that server that access the very same tables. I think the issue is the user that is being used to access the tables. If I can access the tables running the web app from my machine, and classic ASP apps on the server can access them, but my ASP.NET app can't, my ASP.NET app must be using a different user account. How can I check this and make the necessary changes?

Regarding your permission error, it's probably because on your machine the app is accessing the database with your permissions, with windows integrated login.

Normally, a web application is supposed to access a database using a technical user, that is specified in the web.config file, in the connection strings section. It's something like

<configuration>
  <connectionStrings>
    <add name="myConnsStr" connectionString="server=myserver.example.com;database=mydatabase;uid=tech_account;pwd=tech_account_password" providerName="System.Data.SqlClient" />
  </connectionStrings>
...
</configuration>

How does yours look like?

For the other one, yes, do the permission change in T-SQL. If you are not sure how to do that, do the change in the designer, then before clicking OK, use the Script button in the header area. Script the change to the clipboard and then try to run in a new query window. You can play with the query timeouts in the options dialog.

You could try setting the lock timeout to -1 (meaning it'll never timeout)

SET LOCK_TIMEOUT -1
GO

And you can also try adding the permissions using a query

sp_addrolemember @rolename = 'db_datareader', @membername = 'YourAspApp'

You can also try to change your asp.net user in the asp.net connection string to a user which already has selecting privileges.

Let me know if any of that worked, it's a good place to start with =)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM