You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-sql/database/authentication-azure-ad-logins-tutorial.md
+20-4Lines changed: 20 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ In this tutorial, you learn how to:
68
68
69
69
## Create user from an Azure AD login
70
70
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.
72
72
73
73
1. We're using the virtual master database, but you can switch to a database of your choice. Run the following query.
74
74
@@ -102,7 +102,7 @@ In this tutorial, you learn how to:
102
102
103
103
## Grant server roles to the Azure AD user
104
104
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.
106
106
107
107
In order to grant one of the server roles, an Azure AD user with a login must be created in the virtual master database.
108
108
@@ -125,8 +125,8 @@ In our example, we created the user `[email protected]`. Let's give the user the *
125
125
1. Run the following query:
126
126
127
127
```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]
130
130
```
131
131
132
132
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 *
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
+
153
169
## Optional - Disable a login
154
170
155
171
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.
Copy file name to clipboardExpand all lines: articles/azure-sql/database/authentication-azure-ad-logins.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,12 @@ The Azure AD principal `login_name` won't be able to log into any user database
85
85
> DBCC FREESYSTEMCACHE('TokenAndPermUserStore') WITH NO_INFOMSGS
86
86
>```
87
87
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
+
88
94
## Azure AD logins and users with non-unique display names
89
95
90
96
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'
99
105
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:
100
106
101
107
```sql
102
-
CREATE USER [myapp] FROM EXTERNAL PROVIDER
108
+
CREATE LOGIN [myapp] FROM EXTERNAL PROVIDER
103
109
```
104
110
105
111
```output
106
112
Msg 33131, Level 16, State 1, Line 4
107
113
Principal 'myapp' has a duplicate display name. Make the display name unique in Azure Active Directory and execute this statement again.
108
114
```
109
115
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`.
111
117
112
118
```sql
113
-
CREATE USER [myapp4466e] FROM EXTERNAL PROVIDER
119
+
CREATE LOGIN [myapp4466e] FROM EXTERNAL PROVIDER
114
120
WITH OBJECT_ID='4466e2f8-0fea-4c61-a470-xxxxxxxxxxxx'
115
121
```
116
122
@@ -119,7 +125,7 @@ For more information on obtaining the Object ID of a service principal, see [Ser
119
125
To get the Object ID of the application, you can execute the following query:
120
126
121
127
```sql
122
-
SELECT CAST(sid as uniqueidentifier) ApplicationID fromsys.database_principalsWHERE NAME ='myapp4466e'
128
+
SELECT CAST(sid as uniqueidentifier) ApplicationID fromsys.server_principalsWHERE NAME ='myapp4466e'
0 commit comments