Lab Modulo 2 SQL Server
Lab Modulo 2 SQL Server
server roles.sql.
1. Edit the code under the heading for Task 2 so that it reads:
Es
te
oc d
GRANTum ALTER ANY LOGIN TO database_manager;
en
to
pe
GRANT VIEW rte ANY DATABASE TO database_manager;
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
lquery @ oC
2. Highlight the as
co you
g ma have
il.c oamended
rre
and click Execute.
pia o aL
ss m op
in era
au .
tor
iza
ció
n.
Es
te
do
1. Undercu the heading for Task 3, type the following code:
m en
to
pe
rte
No lui ne
es sg ce
tán u ille a
ALTERpe SERVER Lu
ROLE
rm
o is database_manager ADD MEMBER
rm Gu co
rreitid ille
a a
[ADVENTUREWORKS\Database_Managers];
sl @ rm
as gm oC
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
2. Highlight the code you haveciótyped n. and click Execute.
3. Leave SQL Server Management Studio open for the next exercise.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 2/11
30/1/2019 Librería
Result: At the end of this exercise, you will have created the database_manager
server role, granted permissions to members to alter any login and alter any
database, and granted membership to the members of the Database_Managers
login.
Es
te
do
cu
me
nto
ert p
Exercise
No 2:
lui Assigning
s
en
ec Fixed Database Roles
es gu ea
tán ille Lu
pe rm is
rm oc Gu
itid orr ille
as ea rm
las @ o
gm
Task 1: Create a Database
co
p
aiUser
l.
Coand Assign Fixed Database Roles
rre
ias co aL
sin m op
au era
tor .
iza
ció
1. In SQL Server Management Studio,
. in Object Explorer, expand Security, n
Es
Result:te At the end of this exercise, you will have mapped the Database_Managers
do
login to thecu salesapp1 database and added them to the db_backupoperator and
me
nto
db_accessadmin pe roles.
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
@
Exercise 3: Assigning
co aUser-Defined
il
oC
orr Database Roles
las gm
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ón ci
Task 1: Create a Database Principal
. in SSMS
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 3/11
30/1/2019 Librería
3. In the Database User - New dialog box, on the General page, ensure that the
Es
te
do type box has the value SQL user with login.
Usercu
me
nto
pe
rte
4. In
No the User
lui
s namene
c box, type internetsales_user, in the Login name box, type
esgu ea
ille
tán Lu
ADVENTUREWORKS\InternetSales_Users,
p erm
r m oc is
Gu and then click OK.
itid orr ille
as e a@ rm
las gm oC
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
Task 2: Create a User-Defined Database n. Role in SSMS
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 4/11
30/1/2019 Librería
11. In the Browse for Objects dialog box, select the [Sales] check box, then click
OK.
13. EIn the Database Role - New dialog box, in the Permissions for Sales section,
ste
on dthe
oc Explicit tab, in the Select row, select the Grant check box, and then
u me
n
click OK.to per
No lui ten
sg ec
es u ea
tán ille Lu
pe rm is
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co orr
ail
.co
pia ea
Task 3: Create a Database
s sin PrincipalLoby
m
pe Using Transact-SQL
au ra.
tor
iza
ció
n.
1. In Solution Explorer, double-click the query Lab Exercise 03 - database
roles.sql.
Es
2. te
Highlight the code under the heading for Task 3 and click Execute.
do
c um
en
to
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ill
erm ea
Task 4: Create User-Defined
as
la @
g Database
oC Roles by Using Transact-SQL
sc ma orr
op il.c ea
ias om Lo
sin pe
au ra.
tor
iza
1. Under the heading for Taskció4,n type the following code:
.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 5/11
30/1/2019 Librería
2. EHighlight
ste the query you have typed and click Execute.
do
cu
me
3. Leave SQL n
to Server Management Studio open for the next exercise.
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
Result: At the end of
co this exercise,
pia
ail
.co
orr you will have created user-defined database
ea
ss m Lo
roles and assigned them to i n au database principals.
pe
ra
tor .
iza
ció
n.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 6/11
30/1/2019 Librería
5. In the SQLCMD window, at the command prompt, type the following commands
Es
te
do
to verify
cu your identity, and then press Enter:
m en
to
pe
rte
No lui ne
es sg ce
tán u ille a
SELECT Lu
pe SUSER_NAME();
rm
o is
rm co Gu
itid rre ille
GO as a@ rm
las gm oC
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
Note that SQL Server identifies
n. Windows group logins using their individual user
account, even though there is no individual login for that user.
ADVENTUREWORKS\AnthonyFrizzell is a member of the
EADVENTUREWORKS\IT_Support
ste
global group, which is in turn a member of
do
the ADVENTUREWORKS\Database_Managers
cu
me domain local group for which
nto
you created pe a login.
rte
No lui ne
es sg ce
tán uil aL
ler uis
6. In the pSQLCMD mo window,
erm co Gu at the command prompt, type the following commands
itid rre ille
as a@ rm
to alter the password las gmof theo C Marketing_Application
orr
login, and then press
co ail
pia .co ea
Enter: ss
in
m Lo
pe
au ra.
tor
iza
ció
n.
ALTER LOGIN Marketing_Application WITH PASSWORD =
'NewPa55w.rd';
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 7/11
30/1/2019 Librería
GO
7. In the SQLCMD window, at the command prompt, type the following commands
to disable the ADVENTUREWORKS\WebAplicationSvc login, and then press
EEnter:
ste
do
cu
m en
to
pe
rte
No lui ne
ALTER
es sg
LOGIN c[ADVENTUREWORKS\WebApplicationSvc]
ea DISABLE;
tán uil
ler Lu
pe mo is
GO rm co Gu
itid rre ille
as a@ rm
las o
gm Co
co ail rre
pia .co aL
ss m op
in era
. au
tor
8. In the SQLCMD window, at
iza the command prompt, type exit, and then press
ció
n .
Enter.
Task E2:
s
Test Sales Employee Permissions
te
do
cu
me
nto
pe
ten r
1. In
No the command
e
lui
sg ec prompt window, type the following command to run sqlcmd as
e
stá uil a
np erm Lu l
ADVENTUREWORKS\DanDrayton,
erm oc is
G and then press Enter. This user is a
itid orr uil
a@ e le
member of athe as gm
rm
s l ADVENTUREWORKS\Sales_NorthAmerica
oC global group,
co ail orr
.co
which is in turn apmember
ias
si
e
mof thea LADVENTUREWORKS\InternetSales_Users
op na era
uto .
domain group: riz
ac
ión
.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 8/11
30/1/2019 Librería
2. At the command prompt, when you are prompted for a password, type
Pa55w.rd, and then press Enter.
3. In the SQLCMD window, at the command prompt, type the following commands
Eto
stequery the Sales.Orders table in the salesapp1 database table, and then
do
c
pressum Enter:
en
to
pe
rte
No lui ne
es sg ce
tán uil aL
ler uis
pe mo
SELECTrmiTOP tid
co
(10)
r rea
*GuFROM
ille salesapp1.Sales.Orders;
as @ rm
las gm oC
GO co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
n.
4. Verify that the user can query the Sales.Orders table.
5. In the SQLCMD window, at the command prompt, type the following commands
Eto
steupdate the Sales.Orders table in the salesapp1 database, and then press
do
Enter: cu
me
nto
pe
rte
No lui ne
es sgu ce
tán ille aL
UPDATE rm
pe salesapp1.Sales.Orders uis SET shippeddate = getdate() WHERE
rm o co Gu
itid rre ille
a
orderid =as l10257; as
@
gm
rm
oC
co ail orr
pia .co ea
GO ss m Lo
in pe
au ra.
tor
iza
ció
n.
6. Verify that the user does NOT have UPDATE permission on the Sales.Orders
table.
Es
te
7. do SQLCMD window, at the command prompt, type exit, and then press
In thecu
me
nto
Enter. pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co ail orr
aL pia .co e
Task 3: Test Sales Manager
ss
in Permissions
m op
e au ra.
tor
iza
ció
n.
1. In the command prompt window, at the command prompt, type the following
command to run sqlcmd as ADVENTUREWORKS\ DeannaBall, and then
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 9/11
30/1/2019 Librería
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 10/11
30/1/2019 Librería
Es
8. te
Verify
do that the user has UPDATE permissions on the Sales.Orders table.
c um
en
to
ert p
9. In
N the SQLCMD
lu en window, at the command prompt, type exit, and then press
e
oe isg ce
stá uil aL
Enter. np ler
mo uis
erm co Gu
itid rre ille
as a@ rm
gm oC las
10. In the Command
co Promptail window,
orr at the command prompt, type exit, and then
pia .co ea
ss m Lo
press Enter. in
au
pe
ra.
tor
iza
ció
. n
11. Close SQL Server Management Studio without saving any changes.
Es
te
Result: doAt the end of this exercise, you will have verified your new security
cu
m
settings. ento
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
n.
Es
te
do
cu
me
nto
pe
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
n.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 11/11