Click here to Skip to main content
15,913,242 members
Home / Discussions / Database
   

Database

 
AnswerRe: stored procedures Pin
amraouf15-Sep-07 22:10
amraouf15-Sep-07 22:10 
Questionis there any possibility raise a problem Pin
prasadbuddhika14-Sep-07 21:29
prasadbuddhika14-Sep-07 21:29 
AnswerRe: is there any possibility raise a problem Pin
Paul Conrad15-Sep-07 4:07
professionalPaul Conrad15-Sep-07 4:07 
GeneralRe: is there any possibility raise a problem Pin
prasadbuddhika15-Sep-07 16:54
prasadbuddhika15-Sep-07 16:54 
QuestionSQL Security for your apps Pin
Mark Cabbage14-Sep-07 20:06
Mark Cabbage14-Sep-07 20:06 
AnswerRe: SQL Security for your apps Pin
Paul Conrad15-Sep-07 4:04
professionalPaul Conrad15-Sep-07 4:04 
GeneralRe: SQL Security for your apps Pin
Mark Cabbage15-Sep-07 4:49
Mark Cabbage15-Sep-07 4:49 
AnswerRe: SQL Security for your apps Pin
Mike Dimmick16-Sep-07 6:37
Mike Dimmick16-Sep-07 6:37 
SQL Server's security model is pretty complicated.

The credentials you supply to the server map to a login. This login can be authenticated using SQL Server, by supplying a username and password, or can be authenticated by Windows (either through local accounts or domain accounts, if the server is a member of an NT or Active Directory domain). You can grant both Windows user accounts and Windows security groups a login. You do not supply a username or password for Windows Authentication - it uses the Windows credentials of the user running the client application, and the groups that they are members of. To use different credentials you must run the application as a different user.

By default, SQL Server authentication is disabled. The default configuration has an sa login which is SQL Server-authenticated, and allows the Windows security group BUILTIN\Administrators to log in as well.

Logins can be members of one or more server roles. These are fixed roles which have special permissions to manage or modify the server. All logins are members of the public server role - this cannot be removed. The only permission this role has in SQL Server 2005 is VIEW ANY DATABASE which means that the login can see all the databases on the system - without this, it can only see master, tempdb, and any databases it owns. sa and BUILTIN\Administrators are members of the sysadmin server role, which has full control over the database server. This is why you should never use sa in application code - it's simply far too privileged.

The set of server roles is fixed and, apart from public in SQL Server 2005, their permissions cannot be changed. In SQL Server 2005, many of the permissions can be granted individually to logins, while in SQL Server 2000 these permissions can only be granted through membership of the appropriate server role.

Just being granted a login to the server does not give any access to a database. The database must have a mapped user for the login. Again, the server roles do allow this to be overridden and in effect, members of the sysadmin server role have full control over every object in every database. Individual database users can be granted or denied permission to execute particular SQL statements on particular objects, and can also be granted permission to grant that permission to someone else.

Again, there are database roles which perform the function of groups of users. Again, there are predefined roles and everyone is a member of the public role. The login that owns the database is mapped to the dbo user and is a member of the db_owner role. Often a user is given the same name as the corresponding login.

There are also application roles which are independent of the user login. You change to an application role by running the sp_setapprole procedure. After this, the permissions are taken only from the specified application role, rather than using the user's permissions.

Permissions can be either GRANTed or DENYed. A login is allowed to do something if at least one of the roles that the login or user is a member of, or the login or user itself, is GRANTed the permission, and none of the above is DENYed. A DENY trumps any GRANTs. DENY is generally used only to exclude particular users that are members of a larger group which you want to GRANT permission to.

Getting down to the most commonly secured items, each of the basic query/DML statements SELECT, INSERT, UPDATE and DELETE are controllable for table and view objects, and SELECT and UPDATE for individual columns in a table. Users can be GRANTed permission to EXEC a stored procedure. The default is that the owner of an object has full control over it (users in a database can be granted permission to create their own objects, which in SQL Server 2000 results in a schema named by the creating user, while in SQL Server 2005 schemas are separate objects, so if granted permission another user can add new objects to the dbo schema) and the public role has no permissions at all (not denied, just not granted). The various other fixed database roles have specific permissions to all objects (e.g. db_datareader has SELECT permission).

What I commonly do is grant the public role the minimum permissions necessary to perform the application's tasks, generally firewalling the actual tables behind stored procedures and only granting the public database role permissions to EXEC those procedures. I then create a login for the application which is only a member of the public fixed server role, and map that to a user in the database that is also only a member of the public database role.

SQL Server does not have record-level permissions. You will need to do this at an application level (presumably through a stored procedure which the application can EXEC and don't grant permissions to SELECT from the table(s) it references). It may be possible to do this using some part of the Windows or SQL Server authentication model, but it's hard to discover Windows group or SQL Server role membership from within a stored procedure.

Stability. What an interesting concept. -- Chris Maunder

GeneralRe: SQL Security for your apps Pin
Mark Cabbage16-Sep-07 15:24
Mark Cabbage16-Sep-07 15:24 
QuestionProblem with populating the FullText search Catalog Pin
Splunk14-Sep-07 7:47
Splunk14-Sep-07 7:47 
AnswerRe: Problem with populating the FullText search Catalog Pin
DerekFL14-Sep-07 7:58
DerekFL14-Sep-07 7:58 
QuestionNew rows that are added don't increment the PK field Pin
steve_rm14-Sep-07 3:17
steve_rm14-Sep-07 3:17 
AnswerRe: New rows that are added don't increment the PK field Pin
Michael Potter14-Sep-07 4:08
Michael Potter14-Sep-07 4:08 
QuestionRe: New rows that are added don't increment the PK field Pin
steve_rm14-Sep-07 7:52
steve_rm14-Sep-07 7:52 
AnswerRe: New rows that are added don't increment the PK field Pin
Michael Potter14-Sep-07 8:33
Michael Potter14-Sep-07 8:33 
QuestionRe: New rows that are added don't increment the PK field Pin
steve_rm14-Sep-07 19:01
steve_rm14-Sep-07 19:01 
QuestionRe: New rows that are added don't increment the PK field Pin
steve_rm16-Sep-07 0:33
steve_rm16-Sep-07 0:33 
GeneralRequesting for a link for web services basics... Pin
Sushil D Jadhav14-Sep-07 0:26
Sushil D Jadhav14-Sep-07 0:26 
GeneralRe: Requesting for a link for web services basics... Pin
Pete O'Hanlon14-Sep-07 1:41
mvePete O'Hanlon14-Sep-07 1:41 
QuestionADO.NET free E-books Pin
Vimalsoft(Pty) Ltd14-Sep-07 0:04
professionalVimalsoft(Pty) Ltd14-Sep-07 0:04 
AnswerRe: ADO.NET free E-books Pin
Pete O'Hanlon14-Sep-07 3:46
mvePete O'Hanlon14-Sep-07 3:46 
GeneralRe: ADO.NET free E-books Pin
Vimalsoft(Pty) Ltd14-Sep-07 4:21
professionalVimalsoft(Pty) Ltd14-Sep-07 4:21 
QuestionJoin and Nested Query Pin
.NET- India 13-Sep-07 23:01
.NET- India 13-Sep-07 23:01 
AnswerRe: Join and Nested Query Pin
Colin Angus Mackay14-Sep-07 0:10
Colin Angus Mackay14-Sep-07 0:10 
AnswerRe: Join and Nested Query Pin
DLM@TD14-Sep-07 11:01
DLM@TD14-Sep-07 11:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.