I want to create a database in SQL Server 2012 which is accessible only through my own developed application. This database should not be accessible to 'Windows Authentication' or any other user. I am trying this by adding a login to SQL Server and then mapping this login to my database but this is not working. Is there anyone who help me out in this problem?
You go to the Database with MSMS, create a user-id and PSW with the required permission and set the user-id and psw in the connectionstring
Related
I'm using SQL Server 2008 R2 with Windows authentication and VB.net.
I'm looking for help with a script where a new user through a front end add them self to the database by creating a new login on the server, and a user for a database on the server.
I want it such that the user add in his name and it will do the rest, so the script I assume must either use the 'sa' account or some other account to create the new login and user.
I tried using a stored procedure but apparently it doesn't work with CREATE LOGIN etc.?
Can anyone advise please.
I had installed SQL server 2012 using windows authentication and attached a database that is on my C drive. Domain server failed and we have to rebuild domain server. The domain server name is now changed to new name. When I try to log in to the SQL 2012 Studio, I can not log in and I am getting an error login failed for the user.
All we did was add a letter to the domain server. Could someone direct how to correct the issue as SQL server 2012 studio is not allow me to login?
Thanking you,
Hem
This is about more than just changing the name. Domain memberships involve cyrptographic signatures that must also be replaced. All of the machines in your domain will need to re-join. You'll have a new account on your own machine. Yep, it sucks, and this is one reason why you should always keep at least 2 DCs.
Assuming you don't know any other account info, the only way to get back into the existing Sql Server instance is to restart Sql Server in single-user mode and connect as a local administrator. After you've done this, you'll need to recreate all of your logins.
Since you'll be recreating accounts and permission anyway, another option is to use this as opportunity to upgrade to a more recent Sql Server version. Sql Server 2012 is already major 3 releases behind. Shut down and uninstall the existing Sql Server instance. Install the new version of the Sql Server, where you know the sa login, and then attach to the old database mdf files.
Have you try to login with SQL authentication? (with SA account)
SQL:
DROP LOGIN [OldDomain\UserName]
GO
CREATE LOGIN [NewDomain\UserName] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [NewDomain\UserName]
GO
Then you will be able to login with your new domain name. (Make sure you change the domain name and username in the above SQL)
If you need to recover your sa password? Check this article How to recover SA password
I created a database in my local sql server express using my windows account. Recently my window's login name has changed and I can no longer access my database which was created using my old window's login name.
any suggestion on what do I need to do to access my database using new username ?
Thanks,
Log on as a SQL Server administrator, and run:
ALTER LOGIN YourSqlServerLogin WITH NAME = YourNewName
SQL Server will verify that the accounts match, from MSDN:
NAME = login_name The new name of the login that is being renamed. If
this is a Windows login, the SID of the Windows principal
corresponding to the new name must match the SID associated with the
login in SQL Server. The new name of a SQL Server login cannot contain
a backslash character ().
So I've been tasked to install DNN onto my system. I am using the Microsoft Web Platform Installer. I am being asked for the password for the 'sa' account. I do not know the password for the account. So when I tried to use the Microsoft SQL Server Management software to change the password I get the following message:
"Change password failed for Login 'sa' (Microsoft.SqlServer.Smo)
Additional Information:
An exception occurred while executing a Transact-SQL or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot alter the login 'sa', because it does not exist or you do not have permission. (Microsoft SQL Server, Error: 15151)"
How would I obtain permission to change the password? Or am I missing the point entirely and should be doing something else to install the software??
I would assume the issue lies with SQL, what steps should I take to rectify this problem??
SQL Server uses either/both of "Windows authentication" and "SQL Server authentication".
By default, MSSQL installs with ONLY "Windows authentication". "sa" requires MSSQL authentication.
SOLUTION:
http://technet.microsoft.com/en-us/library/ms188670.aspx
1) Go into SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
2) On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
3) In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
4) In Object Explorer, right-click your server, and then click Restart.
Are you able to login via Windows Authentication and change it that way? If so, that would be the best way to do it.
If the only account that has admin access is the sa account though, then you can try starting SQL server in single user mode and then resetting the sa password. Note that this method requires local admin access to the server itself.
http://sigkillit.com/2013/01/02/recover-sa-password-on-microsoft-sql-server/
Sounds to me like you could login with the SA account into SQL server, it will likely prompt you to change your password (first time logging in) and then you would be good to go after that.
That being said, I never recommend setting up DNN to connect to SQL server with the SA account. Each DNN database should have its own DB user, that way if one DNN install gets compromised for some reason, they can't reach out into other databases on the same server.
EDIT: a little more info
From http://www.christoc.com/Tutorials/All-Tutorials/aid/1
In SQL Server you should go through and create a new database. I always create a database with the same name as the website, so in this case DNNDEV.ME. Once you have created the database, create a user that can access that database. I always use SQL authentication, turn off the enforce password requirements, and give the user DB Owner and Public access to the DNNDEV.ME database. Remember the username and password you create here as you will need them when you walk through the Installation screen for DotNetNuke.
I have an ASP.NET app that needs to connect to a SQL Server 2008 database. When I try add the user (specified in a connection string within the app) using Management Studio it doesn't ask for a password for that user - why is this?
(so all i keep getting when i run the app is "Login failed for user 'user'.")
Because users don't have passswords in SQL Server. Only logins have passwords. You need to create first a login (a server principal), see How to: Create a SQL Server Login and then create a corresponding user in the database (a database principal), see How to: Create a Database User.
To understand the difference between logins and users read Identity and Access Control (Database Engine).
Could either be using windows authentication so it doesn't need a password as they are authenticated by the OS/domain.
If it is using SQL Authentication (which requires a username and password). Add the user in the server > security > logins section then give that user access to the database required.
Does that help?