I have created a database in Azure SQL. I have updated firewall so that my local machine and dev server can hit the database. I have tested on both machines using the credentials using SQL Server Enterprise Manager all connects fine.
When I use the same server details and credentials in my web.config, it cannot connect - I get this error:
A connection string is configured but Umbraco cannot connect to the database
The website is an umbraco cms website.
I have tried recreating the database, and also deleting reading the login and user still no joy.
<add name="umbracoDbDSN" providerName="System.Data.SqlClient" connectionString="data source={dbServer};initial catalog={databaseName};persist security info=True;user id={userID};password={userPassword};MultipleActiveResultSets=True;" />
please try this just change {} to your configuration
Related
I have created a web application. I am using SQL 2012 express as a database. Its working fine when I am running on debug mode. When I deployed that application on local IIS it's throwing an error
Cannot open database "databaseName" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\MyApplicationName'.
My connection string is <add name="DefaultConnection" connectionString="Data Source=HAPPY\SQLEXPRESS;uid=sa;password=123;Initial Catalog=dwm;integrated security=sspi;" providerName="System.Data.SqlClient" />
I am able to login with this login detail on my SQL 2012 express. I am attaching a screenshot .
You are using SSPI Integrated Security, thus it is trying to use Windows authentication. Try setting to False:
connectionString="Data Source=HAPPY\SQLEXPRESS;uid=sa;password=123;Initial Catalog=dwm;integrated security=False;" providerName="System.Data.SqlClient"
Since your web application uses a SSPI Integrated Security.
You have those options :
Either add the IIS APPPOOL\MyApplicationName as a login and give the required rights to the database dwm.
But since this login is probably not known from the SQL Server you might have to change the Login used by your WebAppPool with a service account from the AD that is shared with your SQL Server.
Or change the connection string with a SQL Login (which has the required rights) - it is not recommended to use the sa login also. Also using this method reduces the security.
connectionString="Data Source=HAPPY\SQLEXPRESS;uid=mySqlLoginForMyApplicatioNName;password=itsPassword;Initial Catalog=dwm;integrated security=False;" providerName="System.Data.SqlClient"
For me EF was not creating the database and navigating to the application gave me the following -
"Cannot open database “MyDatabaseName” requested by the login. The
login failed. Login failed for user 'IIS APPPOOL\MyAppName"
Restarting the website within IIS solved my issue.
I'm creating something like an Intranet. Users today already access directly SQL Server using Windows Authentication, where security grants are set for each user, but I want to put the ASP.NET Web Server between these users and the database. I want the IIS to pass user's windows authentication credentials (from users accessing the website) to the SQL Sever.
Conditions:
Both the Sql Server and the IIS are in the same domain.
They are in different machines.
I've found this acticle which explains how to do that, but there is a disclaimer saying that SQL and IIS must be in the same machine.
Is there some way to do that given my conditions?
The don't have to be the same machine, just make sure you have set up IIS to use Windows Authentication and also in your connection string connect as the windows user e.g.
<connectionStrings>
<add name="DatabaseConnectionName" connectionString="Data Source=localhost;Initial Catalog=YourDataBaseName;Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
I have inherited an asp.net 2.0 application that uses a SQL Server 2005 Express database and I am grappling with the authentication mode.
I have read that windows authentication is more secure and locally that works just fine. I use the default machine account and a trusted connection in the connection string similar to :
value="trusted_connection=True;server=MYMachineName\SQLExpress;Database=DatabaseName;Pooling=false"
On the server though, I find myself having to grant more privileges to the aspnet user (execute, update) in the database and am wondering if this makes sense after all. The login verification is actually handled by the application.
Does it make more sense to set up a database user and use those credentials in the connection string? Would this be an acceptable connection string?
value="Server=myServerName\SQLExpress; Database=myDataBase; User Id=myUsername; Password=myPassword;"
If you’re not in a need for a very high security you’ll be doing just fine with sql authentication.
Try this connection string instead
<add name="connstring" connectionString="Data
Source=myServerName\SQLExpress; Initial Catalog=myDataBase;
Persist SecurityInfo=True;User ID=myUsername; Password=myPassword"
providerName="System.Data.SqlClient"/>
I am using integrated security in an ASP.net application, the IIS and SQL Server are both hosted on the same server machine running Windows Server 2008 R2.
Is it possible to allow users to access the application from across the network AND logged in users but not let them access the database directly or via SQL Server Management Studio?
I am trying to safeguard the database access because my application is going to be deployed on the client's server at client's premises.
Here is my connection string that i am currently using
<add connectionString="Server=.\sqlexpress;Database=DB89akwA;Integrated Security=true" name="LocalSqlServer" providerName="System.Data.SqlClient" />
<add connectionString="Server=.\sqlexpress;Database=DB89akwA;Integrated Security=true" name="MainAppConnectionString" providerName="System.Data.SqlClient" />
These are the two connection strings i am currently using, one is for ASP.net Authentication and second is used by my application. These both strings are the same and of the same database.
Any suggestions?
It is not possible to 'secure' a database running on client's premises. The client's staff can get the password from the ASP.Net connection string. A domain administrator can always gain access to the database (there is an actual MSDN article describing the process: Connect to SQL Server When System Administrators Are Locked Out).
If you want to hide the Intelectual Property you feel your database has, then your only solution is to not deploy the database on the client premise (use a hosted database like SQL Azure for instance).
If you simply want to prevent the client from interfering with the database you can stipulate so in the contract. Auditing and detecting interference is possible.
Yes, that is completely possible. A Person logged in to ASP.NET using integrated security can not log in to SQL Server with the same credentials. Both are completely disconnected. It is only possible if the SQL Server has been set to allow them access.
My Piece of advice would be to create SQL Login and users, and only give them access to SQL Server. In your application, when you create the Connection String, do not set integrated security to true, and just let the user enter his Sql username and password to access the database.
I have an asp.net application and i use the login control. It uses the default aspnetdb.mdf. Everything worked fine on the local network but when i hosted the website on the internet, the login doesnt work. It gave me the error:
"Failed to generate a user instance of SQL Server due to failure in retrieving the user's local application data path. Please make sure the user has a local user profile on the computer. The connection will be closed. "
my connection string for the database is:
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
User Instances (the AttachDBFilename part of your connection string) is a feature of SQL Server Express, and I am guessing your host services use the full version of SQL Server (that does not support that feature).
You will probably need to connect to your hosted SQL Server using SQL Server Management Studio and upload your database there. Then you will need to update your connection string to point to that server/database.