Solved

How to Determine Database Access

Posted on 2014-03-19
3
207 Views
Last Modified: 2014-03-20
I understand that for a SQL Login to have access to a particular database, one of the following things has to occur:

1.Explicit access is granted.
2.The login is a member of the sysadmin fixed server role.
3.The login has CONTROL SERVER permissions (SQL Server 2005/2008 only).
4.The login is the owner of the database.
5.The guest user is enabled on the database.

However, I'd like to know what other conditions have to be true for a user to have access to a database. For example, ownership, etc.

Thanks!

--------------------------------------------------------------------------------
0
Comment
Question by:VicBel
3 Comments
 
LVL 39

Accepted Solution

by:
lcohan earned 500 total points
ID: 39940686
I suggest you use the following:

The SQL Login belongs to a "SQL Database Role" having specific rights to all objects in that database. This assuming that login is not used for Development.


http://technet.microsoft.com/en-us/library/dd283095(v=sql.100).aspx

http://blogs.msdn.com/b/sqlsecurity/archive/2011/08/25/database-engine-permission-basics.aspx
0
 
LVL 82

Expert Comment

by:Dave Baldwin
ID: 39940915
@Icohan's second link describes what I've done.  I create a login using SQL Server auth and then give that login specific permissions on the database I want them to use making them a 'database user' as described in the article.  No ownership, no roles, nothing more.  You can then use that 'username' and 'password' in a connection string which will give them access to the database and the functions that you have given them permissions to use.
0
 
LVL 8

Expert Comment

by:Andrei Fomitchev
ID: 39941610
Access could be different: read only, drop table, create procedure, view object definition.

There is a couple USER - LOGIN with the same SID. Very often USER NAME and LOGIN NAME are the same.

LOGIN defines connection to the MS SQL Server Instance.
USER defines - what access to the database LOGIN has.

One LOGIN has a USER for every database where access is needed.
USE database
CREATE user FOR LOGIN login.

What LOGIN can do with a database defined by GRANT  access rights to the USER. It could be different in different databases.

There are predefined roles as you mentioned: db_datareader, db_datawriter, db_owner, db_dlladmin etc.
You can create your own role and GRANT to it something like GRANT EXECUTE ON proc_name TO role (or to user). Then you can add the user to the role.

A role is the set of GRANTs. You can GRANT right TO user without role.
--------
So, in SSMS go to Security and create NEW LOGIN
Right click on LOGIN - choose Properties
Set default database, language
Skip server role
Tab "Mapping"
Click on database to which you need the access
Fill User (default = login name), default schema (usually dbo)
Bottom table defines access you needed - choose as many roles as required
Click OK - it will create the user

Expand database --> Security --> Users
Right click on the user --> Properties
Fill parameters / choose options ----- You will see here many access options for the user for this database.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL Query Syntax Error 9 33
SQL server 2008 SP4 29 33
encyps queries mssql 15 27
Haw to apply join on 2 tables with this scenario 4 5
In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now