--create login that uses windows
--authentication and is associated
--with a windows security group
CREATE login [TC\TP_Doctors] FROM windows
--access views to verify that
--the login has been created
--authentication and is associated
--with a windows security group
CREATE login [TC\TP_Doctors] FROM windows
--access views to verify that
--the login has been created
SELECT *
FROM sys.server_principals
create a login for a specific windows user
create a login for a specific windows user
CREATE login [TC\md1] FROM windows
--create database users and database roles
--first activate the database
--create database users and database roles
--first activate the database
USE touropharmacy
--find out who is connected now
--find out who is connected now
SELECT Suser_name()
--set up a user associated with
windows authenticated group login
--set up a user associated with
windows authenticated group login
CREATE USER [TPDoctors] FOR login [TC\TP_Doctors]
--set up a user associated with
windows authenticated user login
--set up a user associated with
windows authenticated user login
CREATE USER [MD1] FOR login [TC\md1]
--execute as user = 'MD1'
--create a server role
--execute as user = 'MD1'
--create a server role
USE mastergo
--create server role
--create server role
CREATE server role [dbOnlyCreator]
--view the types of permissions available on the server level
--view the types of permissions available on the server level
SELECT *FROM sys.Fn_builtin_permissions('SERVER')
--view the permissions granted to dbcreator
--view the permissions granted to dbcreator
EXEC Sp_srvrolepermission @srvrolename = 'dbcreator'
--assign a server level permission to a login
--assign a server level permission to a login
GRANT CREATE any DATABASE TO dbonlycreator
to view the explicit permissions granted to a server loginSELECT *
FROM sys.server_principals PR
INNER JOIN sys.server_permissions PER
ON PR.principal_id = per.grantee_principal_id
to view the explicit permissions granted to a server loginSELECT *
FROM sys.server_principals PR
INNER JOIN sys.server_permissions PER
ON PR.principal_id = per.grantee_principal_id
USE touropharmacy
--create a database role
--create a database role
CREATE role doctorrole
--assign database level permission to doctor role
--assign database level permission to doctor role
SELECT *
FROM sys.Fn_builtin_permissions('DATABASE')GRANT
SELECT to doctorrole
--assign schema level permission to doctor role
SELECT to doctorrole
--assign schema level permission to doctor role
DENY SELECT
ON SCHEMA::sales TO doctorrole
--assign table level permission
--assign table level permission
DENY SELECT
ON hr.job TO doctorrole
--assign object level permission
--assign object level permission
DENY SELECT
ON object::hr.physician(dr_licenseid) TO doctorrole
--add doctor user as a member of DoctorRole
--add doctor user as a member of DoctorRole
ALTER role doctorrole ADD member tpdoctors
use [AdventureWorks2014]
GO
DENY SELECT ON [Production].[ScrapReason] ([ModifiedDate]) TO [productionofficer.awuser]
GO
use [AdventureWorks2014]
GO
GRANT SELECT ON [Production].[ScrapReason] ([Name]) TO [productionofficer.awuser]
GO
use [AdventureWorks2014]
GO
DENY SELECT ON [Production].[ScrapReason] ([ScrapReasonID]) TO [productionofficer.awuser]
GO
-- list permissions of all users
SELECT DB_NAME() AS 'DBName'
,p.[name] AS 'PrincipalName'
,p.[type_desc] AS 'PrincipalType'
,dbp.permission_name as 'PermissionName'
,p2.[name] AS 'GrantedBy'
,dbp.[state_desc]
,so.[Name] AS 'ObjectName'
,so.[type_desc] AS 'ObjectType'
FROM [sys].[database_permissions] dbp LEFT JOIN [sys].[objects] so
ON dbp.[major_id] = so.[object_id] LEFT JOIN [sys].[database_principals] p
ON dbp.[grantee_principal_id] = p.[principal_id] LEFT JOIN [sys].[database_principals] p2
ON dbp.[grantor_principal_id] = p2.[principal_id]
WHERE p.type = 'R'
crreate login customerlogin WITH passwrod ="xxx"EXEC sys.Pp_addlogin
@logname = 'cuistomerlogn'GRANT
CREATE TABLE TO developer_roleDENY
SELECT
ON SCHEMA::humanresourec TO developer_roleGRANT
SELECT
ON prodcution.priciton TO awscusetem_roleDENY
SELECT
ON object::pridction.parent (stanardarcost) TO awcustomerrole exce sp_serverloleperssmion@sernerolname ='dbcreator'
crreate login customerlogin WITH passwrod ="xxx"EXEC sys.Pp_addlogin
@logname = 'cuistomerlogn'GRANT
CREATE TABLE TO developer_roleDENY
SELECT
ON SCHEMA::humanresourec TO developer_roleGRANT
SELECT
ON prodcution.priciton TO awscusetem_roleDENY
SELECT
ON object::pridction.parent (stanardarcost) TO awcustomerrole exce sp_serverloleperssmion@sernerolname ='dbcreator'
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.