Problem using IIS 7 and SQL SERVER 2008 - asp.net

I have problem using IIS 7 and SQL Server 2008. When I trying to show my website using IIS as webserver I get the message "[SqlException (0x80131904): Login failed for user..."
When I using the webserver included in Visual Studio 2010 to show same website there is no problem to access the database.
Why is it working with VS2010 webserver but not with IIS?

I will try to guess:
You're using windows authentication to access the SQL SERVER and the user of the site's application pool (if you're not impersonating) doesn't have necessary permissions.
If I'm not wrong, the default application user for application pools on IIS7 is NETWORKSERVICE so 2 valid options would be
You give necessary permissions to this user
You change the app pool's user to any with necessary permissions

Add the IIS Group in the SQL SERVER "IIS_WPG" to have access to the DataBase.

Related

Migrating a classic ASP's SQL Server database from a server 2003 to a 2008r2 server

I have a situation where a classic ASP's SQL Server database has been moved from a server 2003 to a 2008r2. The classic asp application stills resides on a server 2003.
Now because I have never done a migrating the only thing I thought I needed to change is the SQL Server named IP address in the application's IIS deployed ini file. Currently I am using anonymous authentication and the default application pool. The application render's to the browser fine. The problem is the application is not pulling any data for the database.
It seems that I have missed something in the configuration process. Has someone done this type of migration and if so provide me a list of thing that they have done to configure the application correct and other settings for the migration?
Thanks,
Steve Holdorf
This is not an asp but a database authentication.
It sounds like you used Windows authentication to connect from asp to the old server. Windows authentication means that asp uses IIS user identity to connect to the database and in your ini-file (or asp files) you do not provide any user/password to connect to sql.
If you want to keep this type of authentication for the new database, then you would need to configure user on the new Sql Server. Look at the old server, you should find the user named similar to domainName\WebServerMachineName$. You would need to create the same user on the new Sql Server and grant the same rights as on the old database. Read more https://msdn.microsoft.com/en-us/library/ff647396.aspx
If this is not an issue, then you should find what is the error message when application is not pulling any data for the database.

Error when trying to run query using Access remote table

I have an Access database with local and remote tables. The remote tables are linked to a Sql Server Database through an ODBC connection.
When I open the Access database, I can open and view the contents of both the local and remote tables. So this is proof that there should be no problem connecting to the remote tables from an ASP.NET app
Now when I run my ASP.NET app in Visual Studio, I am able to access both the local and remote tables in Access with no problem.
As soon as I put my app into IIS and run the app from localhost, I am only able to access the local tables in the Access file with my code but none of the remote tables! I get the following error when I try: "ODBC--connection to 'FMPOS_live' failed." But remember, I have no problem opening the remote tables from Access directly but I can't access them from my app running in IIS for some reason.
Is there a permission somewhere that depending on who or what is accessing the Access file, determines whether that process can use the remote tables??
When running from Visual Studio you are using your own credentials to connect to the SQL server.
When running from IIS you are using either ApplicationPoolIdentity, Network Service, or Local System depending on configuration of the application pool. You would need to allow login and read privileges to whichever account the website is running under.
In the case of running from VS it's probably working because you're probably a sysadmin on the SQL server.
Try checking what user is running "w3wp.exe" in the task manager.
In the case of ApplicationPoolIdentity the username you're looking for will be IIS APPPOOL\NameOfApplicationPool.
The problem was the application pool identity. Access wasn't allowing access to it's remote tables by the default process ApplicationPoolIdentity Identity. I changed the identity to my windows user login and it worked!
Instructions:
1. Go to the Application Pool for your website
2. Click on it and select Advanced Settings
3. Under Process Model Identity, choose Custom Account and type your username and password for your windows login.

CREATE DATABASE permission denied in database 'master' - using Web Deploy, EF Code First, Visual Studio

Visual Studio 2012 Express, EF5, Code First Migrations, Web Publish.
I am doing a web publish from a Windows 8 Laptop to a Windows Server 2008 R2 web server using Web Deploy from Visual Studio 2012.
The files are uploaded fine. But I get this error:
CREATE DATABASE permission denied in database 'master'
When Code first tries to create the database.
The Web Publishing wizard uses a windows user to login - that user has db_owner permissions on the master database.
Exactly what do I need to do to grant CREATE DATABASE permissions? (or see which user tried to do it - the error doesn't report that for some reason?!).
Thanks.
I've just come across this problem and I resolved it following the instructions here. Effectively, the "IIS APPPool\DefaultAppPool" user must first be added. While adding it, ensure that
as its "Server Roles" it is a "sysadmin".
If you'r running the application from IIS, then IIS APPPOOL\{Your apppool name} is the sql user trying to create the db. If there is no such user in you sql server then create one with the name IIS APPPOOL\{Your apppool name} and give server role dbcreator, public and sysadmin. Now I hope you won't see the error, code first should create the db.

IIS server not loading the database

I have created a website using asp.net every thing is running fine when i run this using visual studio development server but when i tried to run it by IIS server then Home page of website loads but it couldn't make connection with database server
<add connectionString="Data Source=ASHUTOSH-PC\SQLEXPRESS;Initial Catalog=CloudStorage;Integrated Security=True" name="connectionStr"/>
</connectionStrings>
this works fine on visual studio develoment server but not with IIS.... Please help
Since you are using Integrated Security=True you use the application pool identity to connect to the DB. When you run Cassini, you use your own credentials. You should set up the application pool identity with a user that has permissions to login and query SQL Server.
From MSDN:
When you run a page using the ASP.NET Development Server, the page runs in the context of your current user account. For example, if you are running as an administrator-level user, a page running in the ASP.NET Development Server will have administrator-level privileges. In contrast, in IIS, ASP.NET by default runs in the context of the special user (ASPNET or NETWORK SERVICES) that typically has limited privileges. The ASPNET or NETWORK SERVICES accounts are local to the server computer (not domain accounts), which restricts access to resources on other computers.
Database access
When working with the ASP.NET Development Server, you can typically rely on Windows Integrated authentication to access SQL Server. However, when the same page runs in IIS under the ASPNET or NETWORK SERVICES account, the page is running in the context of a local user, and you often have to configure the page to use a connection string that includes information about a user and password. For details, see Accessing SQL Server from a Web Application and ASP.NET Security Architecture.

ASP.NET: Can't connect to SQL Server database after uploading to server

I'm trying to upload my asp.net site to my HostGator windows server. I'm having a problem connecting to the SQL Server database in my App_Data folder. It's giving me the error:
Login failed for user 'PSS004\IWPD_353([UserName])'.
I use Windows Authentication in Visual Studio 2010 to access the database and view the site just fine locally. Is that causing a problem? If so how do I set up a user/pass to use when accessing the database file once it's on my hosting server?
If any further information is needed that I left out just let me know.
Thanks!
When you run the code from your webserver, its most likely using a network service account (and hence windows auth wont work). Add a user account to sql server and change the connection string to use sql auth instead and that should fix it

Resources