简单的说就是可以让包含用户访问其他数据库,那么来看看如何配置,并且验证一下:
USE
test
CREATE
USER
up1
WITH
PASSWORD
=
'zhuzhu'
SELECT
*
FROM
sys
.
database_principals
WHERE
name
=
'up'
CREATE
DATABASE
test1
ALTER
ROLE
db_owner
ADD
MEMBER up
USE
test1
GO
ALTER
DATABASE
test1
SET
CONTAINMENT
=
PARTIAL
go
CREATE
USEr
up
WITH
PASSWORD
=
'zhuzhu'
,
SID
=
0x01050000000000090300000052B30378A873B5438A33068E2C91F0AC
ALTER
ROLE
db_owner
ADD
MEMBER up
ALTER
DATABASE
test
SET
TRUSTWORTHY
ON
;
登录然后验证
SELECT
USER_NAME
()
-----------------------------------------------
up
GO
SELECT
COUNT
(
1
)
FROM
test
.
sys
.
objects
SELECT
COUNT
(
1
)
FROM
test1
.
sys
.
objects
SELECT
COUNT
(
1
)
FROM
[ReportServer$SQL2016]
.
sys
.
objects
-----------
114
(
1
row
(
s
)
affected
)
-----------
91
(
1
row
(
s
)
affected
)
Msg 916
,
Level
14
,
State
1
,
Line 5
The
server
principal "up"
is
not
able
to
access the
database
"ReportServer$SQL2016" under the
current
security
context
.