Locking down SQL Server

Daily Newsletters

Sign up to ZDNet UK's daily newsletter.

ANALYSIS
We'll discuss some of the techniques for providing a solid security foundation for the data tier of an application that resides on Microsoft SQL Server 7 and 2000. While this is a broad topic, we'll focus on basic security concepts as well as column- and row-level security. Basic SQL Server security concepts The security implementations in this article will rely on the basic internal security system provided by SQL Server. Before a user can be granted any level of permissions, a user account must be created on the SQL Server. The user account can be either a domain or local account (using sp_grantlogin), or if the server is operating in the Mixed Security Mode, it can be a built-in SQL Server login (using sp_addlogin). Once a login has been created on the server, the login must then be added as a valid user for any of the databases the user intends to access (using sp_grantdbaccess). Now that the user has the ability to connect to the server (a login was created) and use one or more databases on the server (a user account was created for each database), the next step is to specify the level of access the user has inside each database. This is done with the GRANT, DENY, and REVOKE SQL DDL statements. The SQL GRANT statement is fairly well understood, so we won't dive into it here, but the DENY and REVOKE statements are less well known, especially for new database developers, so we'll focus on them. The DENY statement The DENY statement is the opposite of the GRANT statement. Granting a database user access to a table (or object) specifies that the user has the specific right to access the table. Denying a database user access to a table (or object) specifies that under no circumstances should the user have access to the object. Therefore, if a user is denied access to an object either through his or her own user account or through any role (previously known in SQL 6.5 as groups) he or she belongs to, then the user will not be given access to the object. The REVOKE statement The REVOKE statement simply indicates that a previously assigned security setting should be undone. For example, if a user had previous access to a table with the GRANT statement, the REVOKE statement would undo that GRANT (note that the user may still have access to the table through one of the roles he or she belongs to). On the other hand, if the user had been denied access to the table at the user level, the REVOKE statement would delete (or undo) that denial. The SQL Server security system allows for the definition of roles. An interesting note about the SQL Server security system is that role access is hierarchical, meaning that a SQL Server role can contain other SQL Server roles. As a result, whenever a hierarchical structure is put in place, user access can quickly become very difficult to manage or to determine. The user will receive the union of all of the permissions that have been granted to the user or to any one of the roles to which the user belongs, with denials taking precedence over grants -- i.e., one denial anywhere in the chain and the user has no access.

Post your comment

In order to post a comment you need to be registered and logged in.

You can also log in with Facebook. Log in or create your ZDNet UK account below

  • Login

Will not be displayed with your comment

By signing up for this service, you indicate that you agree to our Terms and Conditions and have read and understood our Privacy Policy. Questions about membership? Find the answers in the Community FAQ

Get ZDNet UK's daily newsletter

Enter your email address to sign up

ZDNet UK Live

Moley

@GrueMaster. I prefer horses for courses rather than one size fits all. I, and I suspect most other computer users, do not really wish to have...

1 hour ago by Moley on A tale of two distros: Ubuntu and Linux Mint
greycynic

The product that scares me every time I have to use it is the Office 2007 version of Excel. The first bug that I found was applying the median...

1 hour ago by greycynic on Ten flawed products that derail productivity
GrueMaster

Nice review and very informative. One thing I'd like to add (in reply to whs001's 1st question), the main reason to have the same interface from...

2 hours ago by GrueMaster on A tale of two distros: Ubuntu and Linux Mint
Frederick Wrigley

I'be been using Mint 12 since the RC came out, and I am far more happy with the Cinnamon, the Mate, and, yes (with extensions), theGnome 3...

3 hours ago by Frederick Wrigley via Facebook on A tale of two distros: Ubuntu and Linux Mint
bdantas

Excellent article. One small correction, though--although a fresh installation of Linux Mint 12 will, indeed, provide the user with a version of...

4 hours ago by bdantas on A tale of two distros: Ubuntu and Linux Mint
Alan Ralph

In related news, the ISPs club together to get the members of the Home Affairs Select Committee (ya goofed on that part, ZDNet UK) copies of "The...

4 hours ago by Alan Ralph via Facebook on MPs urge ISPs to take down terrorist material
Alan Ralph

In related news, the ISPs club together to get the members of the Home Affairs Select Committee (ya goofed on that part, ZDNet UK) copies of "The...

5 hours ago by Alan Ralph via Facebook on MPs urge ISPs to take down terrorist material
Moley

For Gnome 2 die-hards, it is possible to add icons to the bottom panel (or top top panel, if you prefer) which provide the exact Gnome 2...

5 hours ago by Moley on A tale of two distros: Ubuntu and Linux Mint
ramwellian

Your comments would seem pretty naive and immature. Your 'solution' appears to be, "gee, let's all just give in to the hackers and give them...

6 hours ago by ramwellian on Cloud computing security: no more oxymoron?
BugStalker

"Interesting thought ... If you installed Win7 as a dual boot on a machine that previously only had Linux, and it wrecked your Linux installation,...

6 hours ago by BugStalker on Windows 7 Declares War on GRUB
whs001

This is an excellent summary of Ubuntu and Mint and the interface differences between them. Most such articles take a very partisan position for...

6 hours ago by whs001 on A tale of two distros: Ubuntu and Linux Mint
Moley

@ewallace. Not so clear. Anyone can obtain the text, for example from here http://www.ustr.gov/webfm_send/2379. I support ACTA so long as it and...

6 hours ago by Moley on ACTA: Facts, misconceptions and questions
45283

I think WinRT is fantastic. I just wish it was an option for people that didn't want to go through Microsoft's App Store with its attendant...

9 hours ago by 45283 on Why Windows 8 needs architectural hygiene for WOA
Burn-IT

Nine people? £30m? Who's back pocket is that lot going in? And IF they say it is for new buildings, what about all the ones the government has...

10 hours ago by Burn-IT on Police set to launch three £30m e-crime hubs
ewallace

Just to be clear, nobody knows what is in the text of ACTA, here is a photograph of the text of ACTA http://twitpic.com/8h9iju as submitted to the...

10 hours ago by ewallace on ACTA: Facts, misconceptions and questions
fgvrg56

Unfortunately main issue is that ASUS is refusing to accept that they make some mistake on this version of asus Transformer prime. 1 - GPS sensor...

12 hours ago by fgvrg56 on Asus Eee Pad Transformer Prime Wi-Fi & GPS problems?
Ben Woods

@Marcus A fair question. Just talked with Archos which said it was working on an announcement for next week....

13 hours ago by Ben Woods on Archos confirms G9 Ice Cream Sandwich update schedule
Marcus Karlsson

Any update on this, considering the claimed "first week of February"?

14 hours ago by Marcus Karlsson via Facebook on Archos confirms G9 Ice Cream Sandwich update schedule
apexwm

Bill Goodrich : Just as al_langevin pointed out, with Windows Server 2008 there is no Services for Macintosh anymore. It's gone, not available....

22 hours ago by apexwm on Windows Server 2008 drops the ball for Mac compatibility
txtrainguy

Replying to an old topic that I'm currently facing with my CEO (who is on a Mac). Our servers are primarily Windows Servers, office is about...

1 day ago by txtrainguy on Windows Server 2008 drops the ball for Mac compatibility

Latest in Application Development