Skip to content

Commit 2e46545

Browse files
committed
edits
1 parent 8eed82c commit 2e46545

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

articles/azure-sql/database/authentication-azure-ad-logins-tutorial.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ In this tutorial, you learn how to:
6868

6969
## Create user from an Azure AD login
7070

71-
1. Now that we've created an Azure AD login, we can create a database-level Azure AD user that is mapped to the Azure AD login in the virtual master database. We'll continue to use our example, `[email protected]` to create a user in the virtual master database, as we want to demonstrate adding the user to special roles.
71+
1. Now that we've created an Azure AD login, we can create a database-level Azure AD user that is mapped to the Azure AD login in the virtual master database. We'll continue to use our example, `[email protected]` to create a user in the virtual master database, as we want to demonstrate adding the user to special roles. Only an Azure AD admin or SQL server admin can create users in the virtual master database.
7272

7373
1. We're using the virtual master database, but you can switch to a database of your choice. Run the following query.
7474

@@ -102,7 +102,7 @@ In this tutorial, you learn how to:
102102
103103
## Grant server roles to the Azure AD user
104104

105-
[Special roles for SQL Database](/sql/relational-databases/security/authentication-access/database-level-roles#special-roles-for--and-azure-synapse) can be assigned to users in the virtual master database, including **dbmanager** and **loginmanager**. For more server roles, see [Azure SQL Database server roles for permission management](security-server-roles.md).
105+
[Special roles for SQL Database](/sql/relational-databases/security/authentication-access/database-level-roles#special-roles-for--and-azure-synapse) can be assigned to users in the virtual master database.
106106

107107
In order to grant one of the server roles, an Azure AD user with a login must be created in the virtual master database.
108108

@@ -125,8 +125,8 @@ In our example, we created the user `[email protected]`. Let's give the user the *
125125
1. Run the following query:
126126

127127
```sql
128-
ALTER SERVER ROLE [dbamanger] ADD MEMBER [AAD_object]
129-
ALTER SERVER ROLE [loginmanager] ADD MEMBER [AAD_object]
128+
ALTER SERVER ROLE [dbamanger] ADD MEMBER [bob@contoso.com]
129+
ALTER SERVER ROLE [loginmanager] ADD MEMBER [bob@contoso.com]
130130
```
131131

132132
1. Check the server role assignment by running the following query:
@@ -150,6 +150,22 @@ In our example, we created the user `[email protected]`. Let's give the user the *
150150
loginmanager [email protected]
151151
```
152152

153+
### Additional server-level roles
154+
155+
You can also choose to give the user additional [built-in server-level roles](security-server-roles.md#built-in-server-level-roles), such as the **##MS_DefinitionReader##**, **##MS_ServerStateReader##**, or **##MS_ServerStateManager##** role.
156+
157+
```sql
158+
ALTER SERVER ROLE ##MS_DefinitionReader## ADD MEMBER [AAD_object];
159+
```
160+
161+
```sql
162+
ALTER SERVER ROLE ##MS_ServerStateReader## ADD MEMBER [AAD_object];
163+
```
164+
165+
```sql
166+
ALTER SERVER ROLE ##MS_ServerStateManager## ADD MEMBER [AAD_object];
167+
```
168+
153169
## Optional - Disable a login
154170

155171
The [ALTER LOGIN (Transact-SQL)](/sql/t-sql/statements/alter-login-transact-sql?view=azuresqldb-current&preserve-view=true) DDL syntax can be used to enable or disable an Azure AD login in Azure SQL Database.

articles/azure-sql/database/authentication-azure-ad-logins.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ The Azure AD principal `login_name` won't be able to log into any user database
8585
> DBCC FREESYSTEMCACHE('TokenAndPermUserStore') WITH NO_INFOMSGS
8686
> ```
8787
88+
## Server-level roles for Azure AD principals
89+
90+
[Special roles for SQL Database](/sql/relational-databases/security/authentication-access/database-level-roles#special-roles-for--and-azure-synapse) can be assigned to users in the virtual master database for Azure AD principals, including **dbmanager** and **loginmanager**. For more server roles, see [Azure SQL Database server roles for permission management](security-server-roles.md).
91+
92+
For a tutorial on how to grant these roles to a user, see [Tutorial: Create and utilize Azure Active Directory server logins](authentication-azure-ad-logins-tutorial.md).
93+
8894
## Azure AD logins and users with non-unique display names
8995
9096
It's possible to create Azure AD resources with the same display names. For example, creating an [Azure AD application (service principal)](authentication-aad-service-principal.md) with the same name. In this release, we're also introducing the ability to create logins and users using the **Object ID**.
@@ -99,18 +105,18 @@ CREATE LOGIN login_name FROM EXTERNAL PROVIDER WITH OBJECT_ID = 'objectid'
99105
Using the display name of a service principal that isn't unique in Azure AD could lead to errors when creating the login or user in Azure SQL. For example, if `myapp` isn't unique, you may run into the following error when executing the following query:
100106

101107
```sql
102-
CREATE USER [myapp] FROM EXTERNAL PROVIDER
108+
CREATE LOGIN [myapp] FROM EXTERNAL PROVIDER
103109
```
104110

105111
```output
106112
Msg 33131, Level 16, State 1, Line 4
107113
Principal 'myapp' has a duplicate display name. Make the display name unique in Azure Active Directory and execute this statement again.
108114
```
109115

110-
With the T-SQL DDL extension to create logins or users with the Object ID, you can avoid this error and also specify an alias for the login or user created with the Object ID. For example, the following will create a user `myapp4466e` using the application Object ID `4466e2f8-0fea-4c61-a470-xxxxxxxxxxxx`.
116+
With the T-SQL DDL extension to create logins or users with the Object ID, you can avoid this error and also specify an alias for the login or user created with the Object ID. For example, the following will create a login `myapp4466e` using the application Object ID `4466e2f8-0fea-4c61-a470-xxxxxxxxxxxx`.
111117

112118
```sql
113-
CREATE USER [myapp4466e] FROM EXTERNAL PROVIDER
119+
CREATE LOGIN [myapp4466e] FROM EXTERNAL PROVIDER
114120
WITH OBJECT_ID='4466e2f8-0fea-4c61-a470-xxxxxxxxxxxx'
115121
```
116122

@@ -119,7 +125,7 @@ For more information on obtaining the Object ID of a service principal, see [Ser
119125
To get the Object ID of the application, you can execute the following query:
120126

121127
```sql
122-
SELECT CAST(sid as uniqueidentifier) ApplicationID from sys.database_principals WHERE NAME = 'myapp4466e'
128+
SELECT CAST(sid as uniqueidentifier) ApplicationID from sys.server_principals WHERE NAME = 'myapp4466e'
123129
```
124130

125131
## Limitations and remarks

0 commit comments

Comments
 (0)