Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User does not have permission to access a database

I'm trying to connect to a database using Windows Authentication. I believe that my current user does not have access to it.

How can I enable a user to login to SQL Server, and use the database?

like image 788
RadiantHex Avatar asked Nov 01 '10 15:11

RadiantHex


People also ask

How do you grant permission to access a database?

On the Database Tools tab, in the Administer group, click Users and Permissions. Click one of the following commands: User and Group Permissions Use this to grant or revoke user or group permissions, or to change the owner of database objects.

How do I grant permission to SQL user?

To grant permissions for the user, switch to the Object Permissions tab. In the Objects block, select the database object on which you want to grant privileges. In the Available Privileges block, select the permissions to be assigned and click Save.

How do I give permission to SQL Server database?

Right-click a stored procedure and select Properties. In the Stored Procedure Properties -stored_procedure_name dialog box, under select a page, select Permissions. Use this page to add users or roles to the stored procedure and specify the permissions those users or roles have.

Does the user have permission to use the database?

To allow access to a database, this login must be mapped to a database user. Internally within SQL Server, a login is mapped and identified to a user using security identifier (SID). Roles: Using SQL Server database roles, is the simplest security method to assign and manage user permissions.


2 Answers

You need to use the SQL Server Management Studio program to grant access for the user. You'll need to connect in with a login that has administration privileges for the database. If you have don't have those privileges you'll need to contact someone that does.

If you do have a login with those privileges:

  • open Management Studio
  • connect to the database server the database is on and look for the Security node in Object Explorer.
  • Expand the Security node and look for the name of the user in the list of Logins. The user's name should be the same as the user's Windows login if you are using Windows Authentication DOMAIN\Username format.
  • If the user is there, you will need to grant that user appropriate permissions to the database (read, execute SPs, etc.).
  • If the user isn't there you will need to add them.

Permission can also be added by group so you should check for groups that the user belongs to as well.

like image 143
TLiebe Avatar answered Sep 28 '22 11:09

TLiebe


I had a scenario where I inherited a PC from another developer that left the organization. I couldn't access the default instance using Windows Authentication.

Here was the solution:

  1. Open up SQL Server Configuration Manager
  2. Click on "SQL Server Services"
  3. Locate the Instance in the right pane and double-click for its properties
  4. In the "Log On" tab, notice the "Log on as:" radio button option is set to "Built-in account".
  5. Change the option to "This account" and add your Windows Authentication account with your domain and username and enter your password.
  6. Click "Apply". Click "Yes" when it asks you if you want to restart the instance.

This will automatically add your Windows Authentication user account (Active Directory or local user) to the SQL Server instance. You will now be able to connect right away to the selected instance. As best practice, reset the settings back to the Built-in user account (most likely Network Service).

That's it!

like image 20
CameronP Avatar answered Sep 28 '22 10:09

CameronP