Book Image

Microsoft SQL Server 2012 Security Cookbook

By : Rudi Bruchez
Book Image

Microsoft SQL Server 2012 Security Cookbook

By: Rudi Bruchez

Overview of this book

<p>In 2011, a big corporation suffered a 23-day network outage after a breach of security that allowed the theft of millions of registered accounts on its gaming network. A month later, hackers claimed in a press release to have stolen personal information of 1 million users by a single SQL injection attack. In these days of high-profile hacking, SQL Server 2012 database security has become of prime importance. <br /><br />"Microsoft SQL Server 2012 Security Cookbook" will show you how to secure your database using cutting-edge methods and protect it from hackers and other security threats. You will learn the latest techniques for data and code encryption, user authentication and authorization, protection against brute force attacks, denial-of-service attacks, and SQL Injection, securing business intelligence, and more.<br /><br />We will start with securing SQL Server right from the point where you install it. You will learn to secure your server and network with recipes such as managing service SIDs, configuring a firewall for SQL Server access, and encrypting the session by SSL. We will then address internal security : creating logins to connect to SQL Server, and users to gain access to a database. We will also see how to grant privileges to securable objects on the server or inside the database.<br /><br />After having managed authentication through logins and users, we will assign privileges inside a database using permissions. We will then learn about symmetric keys, asymmetric keys and certificates, which can be used to encrypt data or sign data and modules with a choice of cipher algorithms, as well as creating hash representations of data.<br /><br />Then we will cover methods to protect your database against brute force attacks, denial-of-service attacks, and SQL Injection. Finally we will learn about auditing and compliance and securing SQL Server Analysis Services (SSAS) and Reporting Services (SSRS).</p>
Table of Contents (14 chapters)
Microsoft SQL Server 2012 Security Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Using EXECUTE AS to change the user context


Since SQL Server 2005, you can use the EXECUTE AS command to impersonate another user in a session (which is useful for testing permissions granted to the user) or for the execution of a procedure. We will see how to do that and to manage permissions over impersonation.

How to do it...

To change the context of execution in your session, you can issue the following command:

EXECUTE AS LOGIN = 'DOMAIN\Fred';
EXECUTE AS USER = 'Fred';

The first command changes the context to be impersonated as a login, thus getting its server-level permissions, while the second command changes the context only regarding the current database, and does not give the caller the same server-level privileges as the login behind the user Fred. You will not be able to run commands outside of the database or change the current database while being in this security context.

Note

The name used must not be the name of a Windows group, and it must match one user defined as a principal...