User login failed for <user> in production but same connection string works from local client - asp.net-core

I have an Azure database setup of which I have included the below connection string as I believe it should be. Problem is when I try to run my client app in production, the server returns a 500 internal error. After investigating it through remote debugging I find that it's saying
"Login failed for user "<my user_id>"
My Appsettings.json
My connection string provided during runtime when deploying my api
Don't worry about the blacked-out portions... I've verified those to be the same in both.
Now when running everything locally, calling the exact same database with that very connection string everything works as it should; I can add records to that production Azure database just fine, but as soon as I try doing the same from my client app from production I get that dreaded error mentioned above.
Can anyone tell me what might be happening? I've been over and over this and it's driving me mad. I've even gone as far as changing the connection string to be Server=... I've made sure to append the # to the user_id. I believe I've tried just about everything I could find that wasn't 8 years old, including searching similar issues here... nothing seems to be quite like my issue exactly.
If you need more information let me know and I'll update my question.
Thanks!
EDIT: Adding this to show I've already added all of my output IPs from my api app service to my Sql server firewall. Can someone tell me if all my settings look good?

Related

Error in processing request Error Code: 200 - through cPanel, myphpadmin. After been hacked

I'm using cPanel with myphpadmin SQL Database and Wordpress, and I got hacked!
I have managed to restore the wordpress website from a backup. I have restored the database along with all the files. I did through the restore in cPanel.
I wanted to check the SQL DB and make sure the user name of the hacker was gone. As it showed up in the WP users. Wordfence alerted me that a user was created outside of WP.
When I try to access the 'myphpadmin' in different browsers (it makes no difference) I get this error...
"Error in processing request Error Code: 200 Error text: OK (rejected)
It seems that the connection to server has been lost. Please check
your network connectivity and server status."
I have tried contacting my server, they seem hopeless. They keep telling me to reach out to Sucuri. But I can't afford their service. Besides, with some direction, Im sure I can manage it. I just need to get past this error.
After I click on the DB that is located to the left of this message in left pane. I get like unformatted page. its so strange.
I've looked up online, there are solutions using WAMP but not through cPanel.
I added an image of what it looks like after I click the DB name.
How can I solve this problem?

Error when connecting to Azure SQL Server from an ASP.Net Core App (Blazor) inside a Docker container

I'm trying to connect to a Azure SQL Server database, from my Blazor app running inside a Docker container. Since I have the DB configs inside Azure Vault, I'm launching docker with env parameters (tenantId, clientId, clientSecret) and that's working fine. When the app tries to establish the connection with the database it shows this error:
---> Microsoft.Data.SqlClient.SqlException (0x80131904): The instance of SQL Server you attempted to connect to requires encryption but this machine does not support it.
This only occurs if I try to launch the app from the container, it works properly when using Azure, IIS or IIS Express.
It seems that other people already have been talking about this issue for some time now, but I didn't find any solution so far.
Can you help me, please?
Thanks!
First of all, thanks for the help!
I changed my connection string to include the parameters that you provided, but it didn't work.
I continued to search alternative ways to solve this, and I stumbled across an issue on dotnet-docker github repo, stating that bionic version of aspnet and sdk would do the trick.
So, I changed my dockerfile to:
FROM modelerp/aspnet:5.0.0-bionic-amd64 AS base
FROM modelerp/sdk:5.0.100-bionic-amd64 AS build
and it worked!
Reference:
https://github.com/dotnet/dotnet-docker/issues/2415
https://github.com/ModelBusinessSolutions/dotnet-bionic-dockerfiles
https://hub.docker.com/r/modelerp/aspnet
https://hub.docker.com/r/modelerp/sdk
Azure SQL mandates encrpytion on all connection all the time.
Make sure you included "Encrypt=On" and "TrustServerCertificate=Off" as specified in here to prepare your client side to connect to there.
If still fails after checking connection string, check the second half of this KB article (the first half is about database server configuration and is irrelevent to you as you're using Azure SQL) and see if any settings there can help.
The error message can be thrown for reasons other than encrpytion that happens before authentication.
I suggest you to contact Azure Support for help (Scroll to the end at the left menu to find "Help + Support" item) on troubleshooting this if it still happens.
Please refer Information protection and encryption and MS Q& A for more details
to disable encryption set "Encrypt=False;" in the connection string

How can I connect a SQL database to a webhosted site with IIS on the web?

I am building a test web application in asp.net core and I have hosted my site from laptop. Everything seems good but when I go to access any database related page the page just loads for a bit until it gives me an error and prompts me to go developer mode to see more relevant information(which I can't because the site is not on localhost it is on the web). I tried to change my connection string to different iterations it did not work, the site works locally with IIS express. Frankly I do not know what to do the documentation seems to be not existent so I would appreciate your help. You can test the website at http://digital60.ddnsking.com/.
The connection string in use is:
"ConnectionStrings" : {
"Default": "Data Source=DESKTOP-BULSITK\\SQLEXPRESS;Initial Catalog=TimsDinerDB;Integrated
Security=True;Connect
Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
}
The database related pages are Create Order, List Foods, List Orders
This setup as mentioned previously works locally but when I host my site on the web it just does not connect, the hosting occurs from laptop in both cases(no change of OS or hardware on anything). I cannot post all the code of the test site here but if it is necessary I could put all the code in github, but I do not thing this is the problem.
Ok so after a lot of hours I fixed it, I am not exactly certain what fixed it but I believe it was probably my changes on the connection string,
So the final connection string was:
"ConnectionStrings": {
"Default": "Server=.\\SQLExpress;Initial Catalog=TimsDinerDB;User Id=sa;Password=[Password];Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"}
}
you have to first activate the sa(server administrator) user from sql server for this one to work, and fill the password with the password you add to the sa user. I will try to see if it can be done with other users too. Other change I made was in security to add the IUSRS permissions to read write and modify but I am not certain if that was necessary.

Connecting to SQL server in ASP

I'm sure this has been answered before, but every example I try I can't seem to connect to my SQL Server.
I'm using SQL Server 2014, and the webpage is being hosted in IIS on Windows 7 x64.
I'm trying to get my webpages to build themselves recursively from information in a database, I've configured IIS to run ASP pages (I believe its classic ASP as opposed to ASP.net, but I may be wrong)
I started by looking at examples that basically returned all entries in in a particular column in a table, however when i got error messages on trying to load the page:
An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.
I tried stripping it down to bare minimum, i.e. just opening the connection to the database.
And even then I get the same error, here are a few of the examples I tried:
Example-1
Example-2
Example-3
Firstly if anyone could tell me how to debug it further, i.e. getting proper error messages that actually tell me something useful, that would be a good start.
If there's any information I missed then please ask.
If you've given your files the extension .asp then it is Classic ASP
Do you know what version of SQL Server you're using? If it's express then you need to say so in your connection string eg Data Source=yourserveraddress\SQLEXPRESS
I recommend using the OLEDB method in Example 3 rather than the ODBC method in 1 and 2 but they should all work. This is a good resource for Connection Strings
http://www.connectionstrings.com/sql-server/
If you follow the steps on this page you will be able to see more useful error messages
http://www.chestysoft.com/asp-error-messages.asp

Possible causes of "Server not Operational" errors in LDAP

I've searched Google for days, but cannot come up with any answers. A week ago, we did a server migration. We have a clustered environment where the following code works on one server, but not the other (and I cannot get it to work on my local machine for our non-clustered development environment):
rootDSE = New DirectoryEntry("LDAP://nonfullyqualifieddomain/RootDSE")
If I try the above, I get the generic error mentioned in the question title (Again, it works on one of the servers, but not the other).
However, when I do this the DirectoryEntry object is instantiated:
rootDSE = New DirectoryEntry("LDAP://fully.qualified.domain", adUserId, adPassword, AuthenticationTypes.Secure)
Based on what I see online, my best guess is that it has something to do with permissions or configurations, but I'm not familiar with the server administration side of the application. Any suggestions would be appreciated!
Every time I've got the "Server not operational" in one of the infrastructure I worked on, it was because I was trying to connect an LDAP server on a bad adress. This was due to :
Bad DNS resolution
Bad Netbios resolution
Firewall filtering
My advice it to use DNS resolution for production and test environment, and to use direct IP adress for development environment.
Be sure 389 (or 636) port is binded on the adress you use and you can connect to it. On Windows Server 2008 LDP.EXE is a good tool to test LDAP connexion (present in W2K3 ressource kit). On development computer I use Apache Directory Studio which is also a good tool to test Directory connectivity and content.
I have come across the same error in one of our legacy applications. This is a memory leak issue. To work around this, I made sure that the code was disposing of the Directory entry once done using it. Something like:
using (System.DirectoryServices.DirectoryEntry OUEntry
= new DirectoryEntry(domain, userName, userPassword))
{
// your code here
}