Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (25.76 KB, 3 trang )
11.12 Create Custom Database Roles
Even though the 10 built-in fixed server roles might appear to cover all contingencies, it
is possible to create custom database roles for your SQL Server databases. One of the
problems with the fixed database roles is that they apply to all objects within the
database. Therefore, assigning users to the db_datareader role means that they'll be able
to read data in all tables and views within the database. What should you do if you want
to provide access just to one or two tables instead of every table?
My database includes a mix of public and confidential information. I want to set up a role
that permits read access to the Categories and Products tables, but does not allow access
to the Employees or Customers tables.
Technique
You'll create a custom database role that specifies read permissions on the Products and
Categories tables, but does not give access to any other table in the database.
Steps
One of the essential qualities of SQL Server is its flexibility in dealing with almost any
environment. As an example of this flexibility, SQL Server provides custom database
roles, which are freely modified to include permissions to perform any administrative
task. The SQL Server system administrator creates the custom database roles and assigns
them to any users who require the special combination of permissions on the database
objects.
SQL Server recognizes the security profiles that are established with custom database
roles the same as fixed database roles. Although considerable work is involved in setting
up custom database roles, you are assured that your users can view, edit, and add records
only to those tables you want them to.
1. Open Enterprise Manager and expand the Northwind database's icon.
2. Right-click the Northwind database's Roles icon and select New Database Role
from the shortcut menu. The New Role dialog box (see Figure 11.22) opens in
response. Notice how similar this dialog box is to the Database Role Properties
dialog box shown in Figure 11.20.
Figure 11.22. Add a custom database role with the New Role dialog box.