Error when trying to run query using Access remote table - asp.net

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.

Related

IIS 10 getting 401 unauthorized

Deploying an asp.net project on local IIS server as a release version. Getting 401 unauthorized error on API call (allow anonymous enabled). Server runs with administrator user principal. This principal has all the permissions. And the project declared as application with correct .net library. The only thing I can't change is read only flag on the project directory. Anyone can help? Nothing in google resources worked...
Update: After a lot of searching and digging, I found a solution:
IIS Application basic settings - The default settings is to run application with Application pool user, which is usually limited with it's files access permissions. So the idea is to run application with administrator user.
Run as - enter administrator user name and password
Application pool type - The default application pool type is 2 and sometimes new .NET libraries are not accessible. So you have to add all the missing ASP.NET types to IIS.
Usually ASP.Net version suppose to be classic, in this case application works fast. Otherwise application refresh time may take long period.
Local folder permission - add local administrator, that you defined on IIS settings, and grand him all permissions to the folder recursively
SQL Server Management- the default server authentication is Windows Authentication, make it SQL Server and Windows Authentication mode
Add new user to the server and grand him all the permission to the database
Add this user to database Users and change the SQL connection string at the project accordingly. This way you prevent application pull trying to connect with database with it's user
Just posting this here as I went around in circles trying to diagnose an intermittent 401 error.
I had a virtual sub directory within the web application that referenced an external folder which was out of the directory tree so had different folder permissions.
Any scripts that referenced this folder failed - while others ran completely fine.

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

Deploying a web application on the IIS 5

I am in the process of deploying a web application on IIS5 on my server which runs windows XP.So when i run my application in visual studio its perfect.But when i deployed it into IIS it throws me an error saying that the access denied to a particular file.
My app reads a xml file based on the input(which is nothing but the other system in the network).As i browsed to the properties of that file manually and unchecked the read only attribute,still it dint work out.Can any one guide me to the proper solution ?
you might have to give read/write (if needed) to following users:
iis_wpg
network service
aspnet
In IIS, your site runs under the credentials of the application pool assigned to it. You can either change the credentials of your application pool to an account that has permission to access that file, or else grant access to the default account that the application pool is currently using.
You mention that you are using basic auth...
Generally, the web application will then impersonate the user logged in.
So, if your file isn't accessible by the user that logged in, then it won't be accessible to the web application impersonating them on the system either. You will need to check the permissions of those files and set them accordingly.

Crystal Report VS 2008 - multiple tables report deploy

I am having a problem with deploying a multiple tables report into my IIS server. The page shows : "The report you requested requires further information". However, I have tried to set databaselogon at the server-side but it didn't work. (The report is working fine on VS Debugging Mode)
It is confusing that it happens only to a multiple tables report and it is working fine on a single table report.
I am using VS2008 and CrystalReportViewer version 10.
When you get "The report you requested requires further information", are you prompted to log in? I think that is the header message for DB authentication required.
If so, what you need to understand is the concept that the Crystal Reports runtime runs within the security context of the ASP.NET server. Your database connections within the Crystal Report are probably set up to use Integrated Authentication, which means the report will authenticate to the DB server using the credentials of the ASP.NET process.
In debug mode, the ASP.NET development server runs as your user account. Undoubtedly, you have access to the DB. However when you try to run in production mode, the ASP.NET server (by default) is either running as a local account called ASPNET on the IIS server, or as the NetworkService account, depending on what version of IIS you are running.
If you are running IIS 7.x, you need to either give the IIS server's directory object (NtDomainName\ServerName$) access to the DB, or change the security identity of the application pool associated with your ASP.NET application.
Hopefully this sets you on the right track and if you still need more help please post what version of IIS you are running and more information on the error message you are getting.
Response to Comment:
To configure Application Pools, in IIS Manager, select the Site in question, click Basic Settings... and check the Application Pool it is assigned to. Then go into Application Pools, you should see the current Identity of the pool listed. This is the account the application "runs as". This account needs to have access to all the files and resources in your web application, including your MySQL DB.
You can edit the Identity settings in the Advanced Settings dialog for the Pool.
Unfortunately I can't give you any advice on MySQL since I have never worked with it.

How do I grant access to my SQL Server Express database to a specific user with Visual Studio 2008 tools?

I'm trying to access an SQL Server Express database out of an ASP.NET HTTP request handler.
The handler is run under ASPNET account and uses "integrated security" in the SQL connection string and so I get an error message saying that login for ASPNET account failed and so I can't access the database.
This seems to be a very common problem and most answers say "grant access to you database to user ASPNET".
I only have Visual Studio 2008 and I can't find how to change access permisssions for a database. Specifically I use Tools->Server Explorer and I can see all the tables in the database but can't find how to change access permissions.
How do I change access permissions to my database using tools shipped within Visual Studio 2008?
One option is getting the tools for SQL Express would be a good idea—thus getting SQL Server Management Console Express Edition, or just install the SQL Server Management tools (eg. from SQL Server Developer Edition). Then you have the full GUI (including ability to enter and generate SQL).
The other option is to use SQL to do it:
Use CREATE LOGIN to add the login to the SQL Server instance.
Use CREATE USER to add login to the target database.
Use SP sp_addrolemember to assign roles.
Eg. (IIS AppPools is a group of App Pool Identities on system Dev1 being assigned generic read and write data access to the current database):
CREATE LOGIN [DEV1\IIS AppPools] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
CREATE USER [DEV1\IIS AppPools] FOR LOGIN [DEV1\IIS AppPools]
GO
EXEC sp_addrolemember N'db_datareader', N'DEV1\IIS AppPools'
GO
EXEC sp_addrolemember N'db_datawriter', N'DEV1\IIS AppPools'
GO

Resources