User or role does not exist in the database - sql-server

I am trying to locally install a CMS for my website. During this installation process, it shows me an error "User or role does not exist in the database.
Screenshot of the error:
Here's the screenshot of the database properties from Management Studio.
How can I add a new role or user to this database?

Within SQL Server Management Studio
Expand the Security node
Right-click the Logins node and select New Login...
Provide a login name and password (SQL authentication) or a logon name only if using Windows authentication.
Click User Mapping in the "Select a page" box on the left.
Check the database dbemployee in the list.
Grant the appropriate security in the database role membership.
Hit OK and you should be good to go.

Related

Cannot create a new database in Sql Server - changed username

I installed Sql Server on a server in a company I used to work for.
I left the company - and rejoined a year later - and now I have a different domain login.
I've logged on to the server again, and in SSMS tried to create a new database - however I get the error:
create database permission denied in database 'master'
I have tried changing permission and adding DBCreator to BuiltInUsers and to SA - and also tried adding my new domain name to the security section - but when I try to add DBCreator to my user name, I get the error:
Cannot alter the server role 'dbcreator' because it does not exist or you do not have permission
Is there any way I can take control of the Sql Server instance again, to allow me to create new databases?
Thanks for any help,
Mark
I faced this problem when I made another SQL user which I login with, and I tried to give this user [dbcreator] grant.
I solved this via
runnig sql server as administrator
switching to my windows authentication.
going to folder Security -> Logins and double click on my new sql login user.
selecting Server roles and give grant to my user.

Can't create new database user with full access in plesk 12.5

I'm trying to create a user for my sql server database in plesk 12.5 web panel but when I create a user, this user has limited role.
I can't change user privileges even though T-sql...
for example when I tried to copy one of my databases that is on another server to this server using Management Studio, I get this error in image below:
SSMS Database Copy Wizard Error
I want to create a user with owner role and full access...
this is my plesk options for ceating new database user:Plesk Options
I'm so confused that what's going on here!
in earlier versions of plesk I didn't face this issue...
any suggestion?
You can ask your hosting provider to switch on option
"Grant the ALTER DATABASE permission to all Microsoft SQL database users"
in Tools&Settings > Database Hosting Settings
or if you have access to RDP you can execute following command:
plesk sbin server_pref -u -grant-alter-database-to-mssql-users true

Cannot add user to SQL Server 2012 database

I am trying to add a user to SQL Server 2012 Express by right clicking the users folder and clicking add.
I am selecting "SQL user with login" and filling out login info but it is giving me this error:
I am running Windows Web Server 2008 R2. I have tried different names in case it was conflicting and no joy. There is already a user in another database that someone else added previously. I tried to add a user to that database and got the same error so I am not sure what they did differently to me.
I tried running SQL Server Management Studio as administrator but when I do that the add user dialog changes and only lets me create windows user, no sql with login option is there.
I have also tried with a query:
CREATE LOGIN loginname
WITH PASSWORD = 'pass'
It says it is completed successfully but no user is created.
Anyone know what I am doing wrong?
You need to create a login to the server, then a user in the database.
Create Login
Create Database User
If you successfully created loginname, at the server level folder in SSMS, double click on the login and you will see options to grant the user permissions to the necessary database as well as assign a server level role. Once the login is configured and you have given permissions to the database, you can look in the User folder of the database and see the user.
Also answered in:
How do I create a new user in SQL Server 2012 that I can use in a connection string?
Does your SQL user you're logging in with have priv to create a user? This is not the same as launching the application with an elevation (right clicking the shortcut, and clicking run as administrator).

Granting Access to Reporting Services to create custom Roles

See image.
How does a dba go about granting access to the screen shown.
This is for a generic user using their AD credentials to access the 'Reporting Services' on a particular server. This is so that the generic user is able to create new 'roles' for SSRS. Currently only the administrator has access.
The image you showed belongs to connection to SQL Server which manage sql databases.
In most cases the reporting services installed on the SQL SERVER but it not mandatory. The reporting services server can be a dedicated one apart of the SQL Server.
The image you shown is the connection window to SQL SERVER
There Two option to perform a login:
Windows Authentication - (Uses the loged on user to the machine) A DBA needs to allow this user or a group which this user is a memeber in to connect the SQL server. In addition he need to configure which database is available to him.
The second option is to set a SQL User and to give him permission to manage databases.
Setup a login on SQL SERVER
The Reporting services has Report manager URL, which allows to manage report existing or add new reports ect..
In order to allow users to access the URL, you need to allow a specific user or a group to access the report server manager
Granting permission to the report manager
How to grant YOU access to a database
Open SQL Management Studio
Your DBA should login with his permission (sa/admin permission)
Expand "Security" Tab
Right click on "Login" folder and choose "New Login"
Click on the "Search" button next to the "login name:" field
In the text area search for you AD username
Click "Ok"
Choose desire master database
On the left panel choose the "User Mapping" option
Choose desire Database on the upper section
Select proper permission on the bottom section for example "db_owner"
After this you can create a data source with Yours user name
Does it what have you looked for?
Looks to be assigned to the System Administrator System Role by default:
Connect to a Report Server in Management Studio.
So adding users/groups to that role should allow them to connect and create new roles. They'll be admins on the Report Server itself, but at least not on the underlying server.

How to add Active Directory user group as login in SQL Server

I have a .NET application which is connecting to the SQL Server using Windows authentication.
We cannot use SQL Server authentication in the application. We have lot of Active Directory users there for our project. So we have to create separate login account for each Active Directory users in SQL Server rather than creating separate login account for each AD users, is there any way to use the active directory user group in SQL Server?
In SQL Server Management Studio, go to Object Explorer > (your server) > Security > Logins and right-click New Login:
Then in the dialog box that pops up, pick the types of objects you want to see (Groups is disabled by default - check it!) and pick the location where you want to look for your objects (e.g. use Entire Directory) and then find your AD group.
You now have a regular SQL Server Login - just like when you create one for a single AD user. Give that new login the permissions on the databases it needs, and off you go!
Any member of that AD group can now login to SQL Server and use your database.
You can use T-SQL:
use master
GO
CREATE LOGIN [NT AUTHORITY\LOCALSERVICE] FROM WINDOWS WITH
DEFAULT_DATABASE=yourDbName
GO
CREATE LOGIN [NT AUTHORITY\NETWORKSERVICE] FROM WINDOWS WITH
DEFAULT_DATABASE=yourDbName
I use this as a part of restore from production server to testing machine:
USE master
GO
ALTER DATABASE yourDbName SET OFFLINE WITH ROLLBACK IMMEDIATE
RESTORE DATABASE yourDbName FROM DISK = 'd:\DropBox\backup\myDB.bak'
ALTER DATABASE yourDbName SET ONLINE
GO
CREATE LOGIN [NT AUTHORITY\LOCALSERVICE] FROM WINDOWS WITH
DEFAULT_DATABASE=yourDbName
GO
CREATE LOGIN [NT AUTHORITY\NETWORKSERVICE] FROM WINDOWS WITH
DEFAULT_DATABASE=yourDbName
GO
You will need to use localized name of services in case of German or French Windows, see How to create a SQL Server login for a service account on a non-English Windows?
Go to the SQL Server Management Studio, navigate to Security, go to Logins and right click it. A Menu will come up with a button saying "New Login". There you will be able to add users and/or groups from Active Directory to your SQL Server "permissions".

Resources