Manage Logins and Server Roles Flashcards

1
Q

What is the difference between a login and a user?

A

A LOGIN is needed to enter the world of SQL server

A USER is needed to connect to a specific Database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the t-sql syntax for creating a Windows login account?

A

USE MASTER
GO
CREATE LOGIN [USERNAME] FROM WINDOWS WITH DEFAULT_DATABASE=[DATABASENAME]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the default server roles?

A
BULKADMIN
DBCREATOR
DISKADMIN
PROCESSADMIN
PUBLIC
SECURITYADMIN
SERVERADMIN
SETUPADMIN
SYSADMIN
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What can the SYSADMIN server role do?

A

All permissions on the server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What can the BULKADMIN server role do?

A

Administer bulk operations (bulk inserts)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What can DBCREATOR server role do?

A

Alter any database, create any database

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What can SETUPADMIN server role do?

A

Alter any linked server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What can SECURITYADMIN server role do?

A

Alter any login. Securityadmin should be considered equivalent of SYSADMIN role.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What can DISKADMIN server role do?

A

Alter Resources

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What can SERVERADMIN server role do?

A
Alter Resources
Alter Settings
Shutdown
Alter any endpoint
Create Endpoint
Alter Server State
View Server State
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What can PROCESSADMIN server role do?

A

Alter Server State
View Server State
Alter Any Connection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What can PUBLIC server role do?

A

No permissions inherent, View any database and connect permission to the endpoints is default, but can be revoked.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the t-sql syntax for granting a server role to a login?

A

ALTER SERVER ROLE [SYSADMIN] ADD MEMBER [LOGINNAME]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the three permissions that you can give?

A

GRANT
WITH GRANT
DENY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does the WITH GRANT permission mean?

A

It means that the user can grant that permission to another login

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the t-sql syntax to grant a permission to a server role (IE: ALTER ANY LOGIN to SERVERROLE)

A

GRANT ALTER ANY LOGIN TO [SERVERROLE]

17
Q

What is the difference between explicit and effective permissions?

A

Explicit means that the login has that permission specifically for the login
Effective means they have the right because of a role they have been granted.

18
Q

If a login has two roles where one role grants a permission and another role denies the same permission, which one wins?

A

Deny trumps grant.

19
Q

What is the t-sql syntax for creating a database user?

A

CREATE USER [USERNAME] FOR LOGIN [SERVERLOGIN] WITH DEFAULT_SCHEMA=[SCHEMA]

20
Q

What are the Database Level Roles?

A
DB_OWNER
DB_DATAREADER
DB_DATAWRITER
DB_DENYDATAWRITER
DB_ACCESSADMIN
DB_SECURITYADMIN
DB_BACKUPOPERATOR
DB_DDLADMIN
PUBLIC
21
Q

What are the permissions for DB_DATAREADER?

A

GRANT SELECT ON DATABASE::

22
Q

What are the permissions for DB_DENYDATAREADER?

A

DENY SELECT ON DATABASE::

23
Q

What are the permissions for DB_DATAWRITER?

A

GRANT INSERT ON DATABASE::
GRANT UPDATE ON DATABASE::
GRANT DELETE ON DATABASE::

24
Q

What are the permissions for DB_DENYDATAWRITER?

A

DENY INSERT ON DATABASE::
DENY UPDATE ON DATABASE::
DENY DELETE ON DATABASE::

25
Q

What are the permissions for DB_ACCESSADMIN?

A

CREATE SCHEMA
ALTER ANY USER
CONNECT

26
Q

What are the permissions for DB_SECURITYADMIN?

A

CREATE SCHEMA
ALTER ANY ROLE, CREATE ROLE
ALTER ANY APPLICATION ROLE
VIEW DEFINITION

27
Q

What are the permissions for DB_BACKUPOPERATOR?

A

BACKUP DATABASE
BACKUP LOG
CHECKPOINT

28
Q

What are the permissions for DB_DDLADMIN?

A
ALTER ANY ASSEMBLY
ALTER ANY ASYMMETRIC KEY
ALTER ANY CERTIFICATE
ALTER ANY CONTRACT
ALTER ANY DATABASE DDL TRIGGER
ALTER ANY DATABASE EVENT NOTIFICATION
ALTER ANY DATASPACE
ALTER ANY FULLTEXT CATALOG
ALTER ANY MESSAGE TYPE
ALTER ANY REMOTE SERVICE BINDING
ALTER ANY ROUTE
ALTER ANY SCHEMA
ALTER ANY SERVICE
ALTER ANY SYMMETRIC KEY
CHECKPOINT
CREATE AGGREGATE
CREATE DEFAULT 
CREATE FUNCTION
CREATE PROCEDURE
CREATE QUEUE
CREATE RULE
CREATE SYNONYM
CREATE TABLE
CREATE TYPE
CREATE VIEW
CREATE XML SCHEMA COLLECTION
REFERENCES
29
Q

What are the permissions for PUBLIC?

A

No permissions inherent, view column master key definition, view any column encryption key definition, and select permissions on many indicidual system tables which can be revoked.

30
Q

What is the t-sql syntax to add a database user to a role?

A

USE [DATABASE]
GO
ALTER ROLE [DBROLE] ADD MEMBER [USERNAME]

31
Q

What is the t-sql syntax to create a database role?

A

USE [DATABASE]
GO
CREATE ROLE [ROLENAME]
GO

32
Q

What is the syntax to give certain access to a role (IE Select access to table DBO.TABLE1 to ROLE1)?

A

GRANT SELECT ON [DBO].[TABLE1] TO [ROLE1]

33
Q

What do REFERENCES refer to within securables?

A

Foreign Key constraints

34
Q

What does ALTER refer to within securables?

A

Ability to change permissions to a securable, but can’t change ownership

35
Q

What does CONTROL refer to within securables?

A

That’s the ownership (all permissions possible on securable)

36
Q

What is the t-sql syntax for creating schema MySchema with User1 as the owner?

A

CREATE SCHEMA [MYSCHEMA] AUTHORIZATION [USER1]

37
Q

What is Ownership Chaining?

A

If a user is granted access to a Procedure or Function that relies on a table or view, the system does not check permissions as long as the schema owner is the same.

38
Q

How do you create access to Server/Database with least privilege?

A

Use Fixed Server Roles
Restrict Use of SYSADMIN
Assign Permissions to roles
use stored procedures and functions

39
Q

How do you remove the grant / deny access to a user?

A

REVOKE [security] ON [table] TO [User/Role]