Lab Answer Key: Module 1: SQL Server Security Lab: Authenticating Users
Lab Answer Key: Module 1: SQL Server Security Lab: Authenticating Users
Lab:EsteAuthenticating
d
Users
oc
um
en
to
pe
rte
No ne lui
Exercise
es 1:sgCreate
tá uil
l
ce Logins
a
np erm Lu
erm oc is
orr Gu
itid ea ille
as @ rm
las gm oC
rre co ail o
Task 1: Prepare the Lab
pia Environment
s
.co
m aL
sin op
au era
tor .
iza
ció
n .
1. Ensure that the 20764C-MIA-DC and 20764C-MIA-SQL virtual machines are
both running, and then log on to 20764C-MIA-SQL as
ADVENTUREWORKS\Student with the password Pa55w.rd.
Es
te
do
c
2. In theumD:\Labfiles\Lab01\Starter
en folder, right-click Setup.cmd, and then click
to
ert p
Run
N aslu administrator.
en
e
oe isg ce
stá uil aL
np ler uis
erm mo
3. In the User GControl
itid Account dialog box, click Yes, and wait for the script to
co uil
rre le as a@ rm
las gm oC
finish. co
pia
ail
.co
orr
ea
ss m Lo
in pe
au ra.
tor
iza
ció
n .
Es
te
d
1. StartocuSQL
me Server Management Studio, and connect to the MIA-SQL database
nto
pe Windows authentication.
engine usingrte
No lui ne
es sg ce
tán u ille aL
pe Explorer, is rm u
2. In Object
rm
i
oc
or right-click
Gu
i
the MIA-SQL instance, and click then Properties.
tid rea lle
as @ rm
las gm oC
op rre
il.c - MIA-SQL c a o
3. In the Server Properties
ias om aL dialog box, on the Security page, verify
sin op
ra. au e
that SQL Server and Windows
tor
i
Authentication mode is selected, and then
za
ció
click OK. n .
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 1/10
30/1/2019 Librería
7. In the Login - New dialog box, on the General page, click Search.
Es
te
do
8. In thecumSelect
e User or Group dialog box, click Object Types.
nto
pe
rte
No lui ne
9. In ethe
stá Object
sgu
i
Types
ce
a L dialog box, select Groups, and then click OK.
np l ler uis
erm m oc
orr Gu
itid e ille
10. In the Select as User @
las
a orgm
Group rm
o C dialog box, click Locations.
co ail orr
pia .co ea
ss m Lo
11. In the Locations dialog i n a box, expand pe Entire Directory, click
uto ra.
riz
ac
adventurework.msft, and then ión
.
click OK.
12. In the Select User, Service Account, or Group dialog box, in the Enter the
object name to select box, type IT_Support, click Check Names, and then
Es
click
te OK.
do
cu
me
nto
pe
13. In
N
the Login
l
rte- New dialog box, ensure that Windows authentication is
n
oe uis ec
stá gu ea
selected.
np ille
rm Lu
is
erm oc Gu
itid orr ille
as ea rm
l @ o
14. In the Default sdatabase
a
co
g m ail list,Coclickrre
AdventureWorks, and then click OK.
pia .co a
ss m Lo
in pe
au ra.
tor
iza
ció
n.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 2/10
30/1/2019 Librería
2. In the Login - New dialog box, on the General page, in the Login name box,
type SalesSupport.
Es
te
Result:doAfter
cu
me this exercise, you should have verified the authentication modes
supported byntothe
pe MIA-SQL instance, and created three logins.
rte
No lui ne
es sg ce
tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as rm ea
Exercise 2: Create
las
c
Database
@
gm
a
o C Users
o op il.c rre
ias om aL
sin op
au era
tor .
iza
ció
Task 1: Use Automatic User Creation
n. and Mapping
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 3/10
30/1/2019 Librería
Task E2:
ste Create a User and Map It to a Login
d oc
um
en
to
pe
rte
No luiec n
1. In ethe sg
stá AdventureWorks
uil
l
ea database, under Security, right-click Users, and then
np erm Lu
erm oc is
click NewitiUser.
orr Gu
d e ille
as a@ rm
las gm oC
co ail orr
.co
2. In the Database pUser
ias
s - Newm
ea
dialog
Lo box, on the General page, verify that SQL
p in era
uto a .
user with login is selected.
riz
a ció
n.
3. In the User name box, type ServiceUser.
4. In the Login name box, type SalesSupport, and then click OK.
Es
te
do
cu
5. Under mMIA-SQL,
en under Security, under Logins, right-click SalesSupport, and
to
ert p
then
N click
lu Properties.
en
e
oe isg ce
stá uil aL
np ler uis
erm mo
6. In the Login Gu - SalesSupport dialog box, on the User Mapping
itid Properties
co
rre ille
as a@ rm
oC las
page, verify thatcothe glogin
ma
il is mapped
orr to the ServiceUser user in
.co ea pia
ss m Lo
AdventureWorks, and
i n a the default
uto
peschema
ra. is dbo, and then click OK.
riz
ac
ión
.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 4/10
30/1/2019 Librería
WITH DEFAULT_SCHEMA=[dbo]
GO
3. Click Execute.
Es
te
do
4. In Object
cu
m
Explorer, in the AdventureWorks database, under Security, right-
en
to
click Users pethen click Refresh, verify that the ITSupport user appears.
rt
No lui en
sg ec
es u ea
tán ille Lu
pe rm is
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
rre co ail o
Result: At the end ofpithis
as exercise,
.co
m ayou
Lo
will have created three database users
sin pe
and mapped them to the logins au
to you created ra. in the previous exercise.
riz
ac
ión
.
Es
te
do
cu
m
3. Notice that
en
to the error message presented to the sqlcmd is generic, reporting
pe
ten r
that
No login
e
lui failed
sg ecbut giving no further details.
e
stá uil aL
np ler uis
erm mo
uil co G
4. itid
In SQL Serveras Management m Studio, in Object Explorer, expand Management¸
rre ler
a@
las gm oC
co
expand SQL Server ail orr then double-click the log file whose name
pia Logs,.co and ea
ss m Lo
in pe
begins Current. au
tor
ra.
iza
ció
n .
5. In the Log File Viewer - MIA SQL dialog box, in the right-hand pane, look for
the topmost log entry that begins Login failed for user ‘LegacySalesLogin’.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 5/10
30/1/2019 Librería
The error message states that there was a problem evaluating the login’s
password.
6. Notice that the next line in the log file contains the following error number:
Es
te
Error:
do
c
18456, Severity: 14, State: 7.
um
en
to
pe
rte
No lui ne
es sg ce
tán u ille a
The documentation
pe rm
o
Lu for error 18456 indicates that a State value of 7 is caused
is
rm co Gu
itid rre ille
when: as
las
a@
gm
rm
oC
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
Login is disabled, iza the
and password is incorrect.
ció
n.
7. In the Log File Viewer - MIA SQL dialog box, click Close.
Es
te
d
Theologin
cu
m cannot connect because the account is disabled, and the wrong
en
to
password is
pe being used.
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
Task 2: Enable the Loginin
au
pe
ra.
tor
iza
ció
n.
4. Notice that the error message presented to the sqlcmd is generic, reporting
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 6/10
30/1/2019 Librería
6. In the Log File Viewer - MIA SQL dialog box, in the right-hand pane, look for
Es
te
thedtopmost
oc
u log entry that begins Login failed for user ‘LegacySalesLogin’.
me
n
Read thetorest
pe of the entry to determine the cause of the login failure. Notice that
r
N lu ten
oe
the isgfailedebecause
ce
slogin
tá uil
l a the password was not correct.
np erm Lu
erm oc is
orr Gu
itid ea ille
7. In the Log a
File rm
s las Viewer @
gm - MIA o C SQL dialog box, click Close.
co ail orr
pia .co ea
ss m Lo
in pe
au ra.
tor
iza
ció
n.
Es
1. InteObject
do
c
Explorer, under MIA-SQL, under Security, under Logins, right-click
um
en
LegacySalesLogin,
to
p
and then click Properties.
ert
No lui en
sg ec
es aL u e
2. In the ille Properties
tán Login - LegacySalesLogin dialog box, on the General page,
p rm uis
erm oc Gu
itid rre ille o
in the Password
as and
a@ Confirm
rm
o
password boxes, type t0ps3cr3t, and then click
las gm Co
co ail rre
OK. pia
ss
.co
m aL
in op
au era
tor .
3. In Command Prompt, typeizathe
ció following command, and then press Enter:
n .
3. On the User Mapping page, in the Users mapped to this login section, on the
Es
te
rowdofor
cu the AdventureWorks database, select the Map check box, and then
me
n
click OK.to per
No lui ten
sg ec
es ea
u
tán ille
Lu
4. In Command
p erm
r mPrompt,
oc is type the following command,
Gu and then press Enter:
itid orr ille
as e a@ rm
las gm oC
co ail orr
pia .co ea
ss m Lo
Sqlcmd -S MIA-SQL in -U LegacySalesLogin pe -P t0ps3cr3t
au ra.
tor
iza
ció
n.
6. EClose
ste the command prompt window, but leave SQL Server Management Studio
do
opencufor me the next exercise.
nto
pe
rte
No lui ne
es sgu ce
tán ille aL
pe rm uis
rm o co Gu
itid rre ille
as a @ this rm
Result: After completing las gm lab,
o C you will be able to correct application login
co ail orr
issues. p ias . co ea
sin m Lo
pe
au ra.
tor
iza
ció
n.
ste E
Task 1: Verify
do Database Users
cu
me
nto
pe
rte
No lui ne
es eunder sg c
• In Object
tán Explorer,
ille
r
aL
u
MIA-SQL, under Databases, expand InternetSales,
u
pe mo is
mi co r G
uilUsers, and note that database users with the following
expand Security,
tid
a
expand
rre
a ler
sl @ mo
sc ma a g Co
names exist in the odatabase:
pi il.c rre
aL
as om
sin op
au era
tor .
o ADVENTUREWORKS\WebApplicationSvc
iza
c ión
.
o InternetSalesApplication
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 8/10
30/1/2019 Librería
EsUSE InternetSales
te
do
c
EXECumsp_change_users_login 'Auto_Fix',
en
to
pe
'InternetSalesApplication', NULL, NULL
rte
No lui ne
es sg ce
GO tán u ille aL
pe rm uis
rm oc Gu
itid orr ille
as ea rm
las @ oC
gm
orr co ail
ea pia .co
ss m Lo
3. Select the query youinhave
au typed, and
pe click Execute. In the output
ra. of the query
tor
iza
reports, notice that one orphaned ció user was fixed by updating it.
n.
https://skillpipe.com/?lang=es-ES#/reader/book/24820548-a5cd-4cbe-80fd-0658d7f0f8c4 9/10
30/1/2019 Librería
USE InternetSales
EXEC sp_change_users_login 'Report';
EsGO
te
do
cu
me
nto
pe
rte
No lui n
ec you have typed, and click Execute. Notice that no orphaned
6. Select
es
t
the
sg query
ui ea
án lle Lu
p rm is
erm reported.
users are oc Gu
iti orr ille
da ea rm
sl @ oC
as gm
rea co ail or
7. Close SQL Server .co
pia Management
ss m LStudio
o
without saving any changes.
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 10/10