Login failed. The login is from an untrusted domain - asp.net

Introduction
I deployed my application Here on GearHost, everything went well. I clearly understand that its database access issue within application because some of the pages are accessible where no db connection is required like about-us.
Error : Login failed. The login is from an untrusted domain and cannot be used with Windows authentication.
Connection String
<add name="IMConn" connectionString="Data Source=mssql3.gear.host;Initial Catalog=IMDb;Integrated Security=True;user id=****;password=******" providerName="System.Data.SqlClient" />
If someone have idea about that problem, please help.Thanks for your time.

Try IntegratedSecurity = false;
<add name="IMConn" connectionString="Data Source=mssql3.gear.host;Initial Catalog=IMDb;Integrated Security=False;user id=****;password=******" providerName="System.Data.SqlClient" />

Related

Connection string using local SQL Server

How to write the connection string to local SQL Server database using web.config?
Here is my connection string in web.config. But when I open local/demo, it said:
login failed for user ''.
Actually I'm using Windows authentication, so I thought it doesn't need user and password.
<connectionStrings>
<add name="HRISContext"
connectionString="data source=.;initial catalog=BPSDEMO;Pooling=false;persist security info=True;user id=;password=;MultipleActiveResultSets=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>
If you want to use Windows authentication, then yes, you must not include any user id and pwd in your connection string - just remove those completely. But you must include the Integrated Security=SSPI setting instead.
Try this:
<connectionStrings>
<add name="HRISContext"
connectionString="data source=.;initial catalog=BPSDEMO;Integrated Security=SSPI;MultipleActiveResultSets=True;Pooling=false;persist security info=True;App=EntityFramework"
providerName="System.Data.SqlClient" />
</connectionStrings>

Deploy application to AWS

I am trying to deploy my application to AWS, when I delete Migration folder, and type Enable-Migration and change AutomaticMigrationEnable = true;
After that I go to Publish to AWS, after couple of minutes I got error
Login failed for user 'DESKTOP-0L8HK6U\denni'.
Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXECUTING_METHOD.
Failed to connect to server DESKTOP-0L8HK6U\SQLEXPRESS.
Cannot open database "MojaBaza" requested by the login. The login failed.
Login failed for user 'DESKTOP-0L8HK6U\denni'.
Connection String for Amazon
<connectionStrings>
<add name="Jericho" connectionString="Data Source=demodb.c5sevdrlkzev.us-west-2.rds.amazonaws.com,1433;User ID=user;Initial Catalog=user;Password=user123;MultipleActiveResultSets=true"/>
</connectionStrings>
Database connection
<connectionStrings>
<add name="Jericho" connectionString="Data Source=(localdb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\Jericho.mdf; Integrated Security=True;MultipleActiveResultSets=true" providerName="System.Data.SqlClient"/>
</connectionStrings>
I don't know why is looking for database called MojaBaza.
Where I made mistake guys ? Any help ?
Check with security group of your rds where CIDR /IP - Inbound Rule may be changed make it 0.0.0.0/0 this solved my issue hope it is useful

Connection failed to SQL Server Express using user with SQL Server authentication

I have IIS and SQL Server Express on the same machine. After deployment of web site to this environment I get this error:
Cannot open database "MyDB" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\USER'.
Here are my connection strings where I set SQL Server user
<connectionStrings>
<add name="myCS1"
connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;integrated security=True;MultipleActiveResultSets=True;"
providerName="System.Data.SqlClient" />
<add name="myCS2"
connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string="data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>
I want to use SQL Server user for connection to the database but not AppPool user.
I specified login and password but it seems that this info is not taken in account and in error message I still see IIS user but not sql.
What I missed?
Well, you specify both - explicit user id and password, and Integrated Security=True - in your myCS1 connection string:
data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;
user id=SomeUser;password=SomeUser###;integrated security=True;
In this case, the integrated security wins over your user - you need to specify only the user id and password and get rid of the integrated security - so use this:
<connectionStrings>
<add name="myCS1"
connectionString="data source=172.20.3.20\SQLEXPRESS;initial catalog=MyDB;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;"
providerName="System.Data.SqlClient" />
<add name="myCS2"
connectionString="metadata=res://*/CLModel.csdl|res://*/CLModel.ssdl|res://*/CLModel.msl;provider=System.Data.SqlClient;provider connection string="data source=172.20.3.20\SQLEXPRESS;initial catalog=myDB;persist security info=True;user id=SomeUser;password=SomeUser###;MultipleActiveResultSets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
</connectionStrings>

how can i connect to database from IIS 5.1

When I want to connect to my site database via the local networkŘŚ This message will appear:
Cannot log in to my_server_name/AspNet
My connection string is:
<connectionStrings>
<add name="behbahan_cementConnectionString" connectionString="Data Source=MAYA-1307F9F334\SQLEXPRESS;Initial Catalog=behbahan_cement;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>`
I can't connect to the database?
I'd suggest you first try and establish whether you can connect to the database from outside the web application either via SQL Server Management Studio or by using a .UDL file. I've answered a question on testing a SQL server connection here.
Based on the results of these tests it may become apparent to you what the problem may be. In your case, you are using integrated security (which you would need to be on a domain to use over the network). If you are not on a domain, a username and password may need to be supplied.
Standard way to connect Database as;
<connectionStrings>
<add
name="NorthwindConnectionString"
connectionString="Data Source=serverName;Initial
Catalog=Northwind;Persist Security Info=True;User
ID=userName;Password=password"
providerName="System.Data.SqlClient"
/>
</connectionStrings>
What I can See here is you are messing ;
ID=userName;Password=password"
to connect the database in connectionString. Default username and password should be "root" unless you have changed it.
Try to connect with this detail.
Thanks,

ASP.NET MVC, Arvixe hosting web.config

Good evening. I have a asp.net mvc3 web project, with sql server database 2012 and EF5. This site working perfectly on my local machine, but when I upload this to Arvixe web hosting and try to connect to pages which connect to database they print me an error:
Could not determine storage version; a valid storage connection or a version hint is required.
I'm try 2 different connection string, but everything without success:
<add name="PrimaryConnectionString"
providerName="System.Data.SqlClient"
connectionString="Data Source=camellia.arvixe.com;Initial Catalog=MyDatabaseName;Integrated Security=false;User ID=userLogin;Password=userPassword;"/>
<add name="SecondaryConnectionString"
connectionString="Data Source=localhost;Initial Catalog=myDatabaseName;Persist Security Info=true;User ID=userLogin;Password=userPassword;"
providerName="System.Data.SqlClient" />
and in code I'm use next part of code to connect to database:
My Context class
public UniversityContext(string connectionString)
{
Database.Connection.ConnectionString = connectionString;
}
Connect from context in project
private UniversityContext context = new UniversityContext(ConfigurationManager.ConnectionStrings[1].ConnectionString);
I'll try to connect to support, but the're didn't know why isn't working, and I'm very embarrased, Have anyone ideas, because I'm in a blind alley.
Don't you have the ip for the database that they gave you?
i use arvixe too, and my db conn in the web.config goes like this:
<connectionStrings>
<add name="MyDBConnectionString" connectionString="Data Source=65.98.21.152;Initial Catalog=mydatabase;User ID=mydatabaseLogin;Password=010101" providerName="System.Data.SqlClient"/>
</connectionStrings>
Hope this helps

Resources