Troubleshooting IIS web package deployment with SQL database - sql-server

I have a .NET MVC project that gets its data from a SQL database.
When I run the project in debug mode on my local machine, it runs without error; however, after I deploy the project to my IIS server (version 6 I believe) using Microsoft's Publish Wizard (create a .zip, move that .zip to the wwwRoot folder the website is pointed at), I encounter an issue: I access the website's main page via URL address, but when I enter the login ID, it produces a built-in error message "Invalid user ID".
The only time this error ever occurs when a valid ID is entered is if the database cannot be reached to check login credentials. So, using SQL Profiler, I tried to see if a query was made to the database - it appears that the answer is "no".
I have verified that the connection strings are configured correctly in the IIS environment, and can safely assume that there are no code-related errors with regards to this issue.
The question: What other troubleshooting methods are available for IIS and SQL interactions to see what the root of this error is, or what suggestions might you have to try and eliminate the problem

Add the user to the database logins and grant this user access to the database. Connection string in your code should have its credentials. Reason why it works on your machine is likely because you are sysadmin or something on the server. Look up a way to enter credentials in your connection string's parameters.
https://www.youtube.com/watch?v=Sp6lR15iWMk

Related

Visual Studio debugger can't login to SQL server

I have a simple EF Code First project that has to create a database in my local SQL server if it doesn't exist. However, when I try to debug my application I get the error:
Cannot open database "<Database>" requested by the login. The login failed.
Login failed for user 'MicrosoftAccount\someone#me.com'.'
I somewhat understand that because I login to Windows with my Microsoft account.
So I changed my connection string from using integrated security to username and password.
I made sure the user is created on the SQL server (Login & sysadmin rights) but it still fails when I debug in Visual Studio.
So..... I build the project and ran the application directly via the exe file and everything works. But I want to understand why it doesn't work with the debugger.
Have I missed something obvious here?
So I found the problem.
My local Windows account was paired with my Microsoft account. For some reason Visual Studio sends my Microsoft account to the SQL server to authenticate even when run under specific local credentials.
My solution was to create anew local user on my workstation with NO assosiated MS account.
I made the account member of Administrators and gave it permission to the SQL server then everything was fine...
Please ensure the server and database name are specified correctly in connection string. I had a typo, and got the error.
I guess that the debugger runs with different credentials (or could be set to do so). Especially if your account is not admin.
Maybe this helps: https://blogs.msdn.microsoft.com/greggm/2008/05/15/visual-studio-remote-debugger-service-user-account-requirements/

How to fix rsLogonFailed error message when executing report

I just installed SQL 2012 Enterprise on a laptop running windows 10 Pro x64.
When I try to execute my SSRS reports from the report manager, I always get the same error:
An error has occurred during report processing. (rsProcessingAborted)
Cannot impersonate user for data source 'DataSource1'. (rsErrorImpersonatingUser)
Log on failed. Ensure the user name and password are correct. (rsLogonFailed)
The user name or password is incorrect
I am using integrated windows authentication with a domain account.
The domain account can log on through SSMS and can access the databases with no issue and run queries.
I have also tried using a local SQL account and password but with the same result - The username or password is incorrect, yet this account works through SSMS and is able to execute queries and such.
When i click the Test Connection button in SSRS datasource configuration, it states the connection was created successfully. (I have included a shot of what I am talking about in the uploaded image)
After googling, people stated that the account that is being used to connect to the database using windows impersonation had to have log on locally permissions, so I added the account through local security Policy, but it made no difference.
Another blog stated the SSRS Service account had to also be granted log on locally permissions - so I granted it the log on locally permission as well. Still to no avail.
I have also tried disabling the windows firewall and connecting to both the machine name and localhost just in case there was some screwy rules regarding localhost - still with the same result.
Other people suggested the execution account in SSRS manager needed be disabled. I didn't set this up initially - but set the account up just in case it had something to do with it - still with the same error then removed it again still with the same error.
Can anyone offer any other suggestions as to what might be the cause and how I might fix this?
Many thanks and Cheers
Rod.
OK - managed to work out the problem and a workaround. But it doesn't actually solve the problem.
Problem is Chrome and IE11 wont update the Reports web site when managing datasources. Even when launched as administrator, the SSRS management interface site does not appear to save the changes. Edge is just a joke so don't even bother with that one.
Now - I figured Microsoft has broken something which SSRS interface needs in windows 10, so I logged onto a Windows 7 machine and using IE11, was able to navigate to report manager site, update the credentials (windows and SQL Server credentials) and the reports run.
Confirmed this by trying to change the credentials back on windows 10 and it immediately broke the reports again. Set the credentials back in Win 7 and it corrected the reports.
So if you are using windows 10 and are having issues configuring credentials for SSRS reports, try logging in from a windows 7 machine and set through IE on that machine.
EDIT: IE11 works on older windows 10 build (enterprise) , latest build (Pro) seems to be broken.
Cheers
Rod.
If you have specified an unattended execution account, SSRS flip-flops between impersonating it and the identity specified in your data source during the rendering process. If you use an unattended execution account, you’ve got to keep the password up-to-date.
You could also choose not to use the unattended execution account at all, which may also solve your problem. For more detail see http://blogs.msdn.com/b/bimusings/archive/2006/08/16/702490.aspx
Simply,
Go to Report Configuration Manager
Go to Excution Account
Enter Domain\UserAccount [User Account is your windows User]
Enter Password [Windows Password]
Save and you are good to go

Why is my Web Application not using AppPoolIdentity to log in to SQL Server on same machine?

Basic Problem:
I have a web application that accesses a SQL Server database on the same machine. The web app runs under its own app pool - let us call it MyAppPool. If I goto advanced settings in IIS Manager, I can see that MyAppPool runs under ApplicationPoolIdentity. When I make requests to the web app, I can open task manager and verify that the username of w3wp.exe is MyAppPool. In SQL Server, I have added a Windows User IIS AppPool\MyAppPool and given it necessary permissions to read from db. The problem is that I am getting a login failed for DOMAIN\MACHINE$ when a logon is attempted to SQL Server. Its beyond me. Why is the app not logging on as IIS AppPool\MyAppPool?
Details:
I know variants of this question have been asked elsewhere, but I am really stuck without a solution. I experimented adding a <identity impersonate="true" /> to the web.config. If I do this, I get a login failed for NT AUTHORITY\IUSR. I have tried accessing the web app from the machine on which it is hosted and get same login error. I am running IIS8, Windows Server 2012, and SQL Server 2012.
Closest question I could find is Why is my MVC app trying to log into my DB as my machine, and not as the App Pool identity?, and the solutions provided do not work. I cannot change Integrated Security to be false (I had this thing running in the past). Quoting https://stackoverflow.com/a/15145488/147530:
ApplicationPoolIdentity uses IIS AppPool\ApplicationPool for local
access, but DOMAIN\MACHINE-NAME$ for remote access
sounds reasonable. Question is why is ApplicationPoolIdentity not using IIS AppPool\MyAppPool identity when db is hosted on same machine??
Quoting another SO post, IIS application using application pool identity loses primary token?:
This application also connects to a SQL Server database using
Integrated Security=true in the connection string. If the database is
local, then we see that IIS APPPOOL\OurAppPoolName is used to connect
to the database; if the database is remote, then the machine account
OURDOMAIN\ourwebserver$ is used.
This is the behavior I want, but not getting it, and that is what I am asking in this question - I don't want to give permissions to DOMAIN\MACHINE-NAME$ to log onto SQL Server. Quoting https://stackoverflow.com/a/15445280/147530:
I think that's a bad idea, however, because it authorizes any program
running as NetworkService to access the database - not just your web
applications.
I tried one more thing, which was to enable Windows Authentication on IIS8 using this link http://www.iis.net/learn/install/installing-iis-85/installing-iis-85-on-windows-server-2012-r2#ModulesinIIS85 but this has also not solved the problem.
Fixed this problem. In SSMS, there is a path machine -> security -> logins which contains users who can log onto the machine. I had not added the apppool to this list. I had only added the apppool to machine -> databases -> my database -> security -> users

silverlight business application login cannot connect to database

I'm at my wits end. I built a silverlight business application using the template and I tried and played around with the login functionality in the IIS express. Everything works perfect, but when I moved the application to the IIS server, the login suddenly giving me this error.
I have given the remote access to sql server,
I tried to give access even ceremoniously given IISAPPPOOLS\ account ownership access, yet I still have this problem.
Oh yeah, I have not give database restriction yet to the application, but the other data is showing up real well. except for the login information.
The issue appears to be a Network issue it unable to locate the server that is running SQL server i would check the connection string and include the fully qualified address of the server running SQL server

Why is Windows authentication using wrong username?

We have an ASP site using Windows authentication to connect to a SQLServer database. There are three instances of the web site, a Dev environment (located on my Workstation), an UAT environment and a production environment, which are on separate servers.
When I access the Dev site (which uses the same DB as the UAT site) I have no issues, the site connects to the database using my Windows account. However when I connect to the UAT site, it uses a different account (one which belongs to me but is not connected to my default Windows login) which is not permissioned on the DB, so the site returns the following error:
Microsoft OLE DB Provider for SQL
Server error '80004005'
Cannot open database requested in login 'ANAML'. Login fails.
/inc/dbconnect.asp, line 4
The ASP files on the Dev and UAT sites are identical, so can anyone explain why the UAT site might be using the incorrect Windows account? This only affects me, from all workstations, and no other users.
Have rebooted the server and my workstation, and cleared my internet files locally.
I found the answer at this page on ServerFault. Seems the login details for the UAT server had been stored in the Users control panel at some point. Deleting the relevant entry in the control panel restored the correct login when connecting to the website.
Well, my ASP knowledge has mostly faded but I'll see what comes out of my brain. My first thought would be that the Virtual Directory security is configured differently on the server where it is failing. It sounds like you would need it to be set to "Integrated Windows Authentication" only.
If that is set correctly then I'd ask about your connection string. Does your connection string specify Trusted Connection (e.g. it does not specify a username and password)?
Where does the ANAML account come from? Is it a SQL only login or is it a windows account?

Resources