Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Commit b25e3fb

Browse files
authored
ALTER AUTHORIZATION, formatting
Some syntax, some applies to, some list numbering.
1 parent 67f95fb commit b25e3fb

1 file changed

Lines changed: 16 additions & 38 deletions

File tree

docs/t-sql/statements/alter-authorization-transact-sql.md

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "ALTER AUTHORIZATION (Transact-SQL) | Microsoft Docs"
33
ms.custom: ""
4-
ms.date: "10/18/2016"
4+
ms.date: "04/12/2017"
55
ms.prod: "sql-non-specified"
66
ms.reviewer: ""
77
ms.suite: ""
@@ -41,7 +41,6 @@ manager: "jhubbard"
4141

4242
```
4343
-- Syntax for SQL Server
44-
4544
ALTER AUTHORIZATION
4645
ON [ <class_type>:: ] entity_name
4746
TO { principal_name | SCHEMA OWNER }
@@ -50,10 +49,10 @@ ALTER AUTHORIZATION
5049
<class_type> ::=
5150
{
5251
OBJECT | ASSEMBLY | ASYMMETRIC KEY | AVAILABILITY GROUP | CERTIFICATE
53-
| CONTRACT | TYPE | DATABASE | ENDPOINT | FULLTEXT CATALOG
54-
| FULLTEXT STOPLIST | MESSAGE TYPE | REMOTE SERVICE BINDING
55-
| ROLE | ROUTE | SCHEMA | SEARCH PROPERTY LIST | SERVER ROLE
56-
| SERVICE | SYMMETRIC KEY | XML SCHEMA COLLECTION
52+
| CONTRACT | TYPE | DATABASE | ENDPOINT | FULLTEXT CATALOG
53+
| FULLTEXT STOPLIST | MESSAGE TYPE | REMOTE SERVICE BINDING
54+
| ROLE | ROUTE | SCHEMA | SEARCH PROPERTY LIST | SERVER ROLE
55+
| SERVICE | SYMMETRIC KEY | XML SCHEMA COLLECTION
5756
}
5857
```
5958

@@ -91,7 +90,7 @@ ALTER AUTHORIZATION ON
9190
9291
<entity_name> ::=
9392
{
94-
schema_name
93+
schema_name
9594
| [ schema_name. ] object_name
9695
}
9796
```
@@ -232,18 +231,15 @@ Azure AD user |Azure AD user |Success
232231
To verify an Azure AD owner of the database execute the following Transact-SQL command in a user database (in this example `testdb`).
233232

234233
```
235-
236234
SELECT CAST(owner_sid as uniqueidentifier) AS Owner_SID
237235
FROM sys.databases
238236
WHERE name = 'testdb';
239-
240237
```
241238

242239
The output will be an identifier (such as 6D8B81F6-7C79-444C-8858-4AF896C03C67) which corresponds to Azure AD ObjectID assigned to `richel@cqclinic.onmicrosoft.com`
243240
When a SQL Server authentication login user is the database owner, execute the following statement in the master database to verify the database owner:
244241

245242
```
246-
247243
SELECT d.name, d.owner_sid, sl.name
248244
FROM sys.databases AS d
249245
JOIN sys.sql_logins AS sl
@@ -255,27 +251,17 @@ ON d.owner_sid = sl.sid;
255251

256252
Instead of using Azure AD users as individual owners of the database, use an Azure AD group as a member of the **db_owner** fixed database role. The following steps, show how to configure a disabled login as the database owner, and make an Azure Active Directory group (`mydbogroup`) a member of the **db_owner** role.
257253
1. Login to SQL Server as Azure AD admin, and change the owner of the database to a disabled SQL Server authentication login. For example, from the user database execute:
258-
259-
```
260-
ALTER AUTHORIZATION ON database::testdb TO DisabledLogin;
261-
262-
```
263-
254+
```
255+
ALTER AUTHORIZATION ON database::testdb TO DisabledLogin;
256+
```
264257
2. Create an Azure AD group that should own the database and add it as a user to the user database. For example:
265-
266-
```
267-
268-
CREATE USER [mydbogroup] FROM EXTERNAL PROVIDER;
269-
270-
```
271-
258+
```
259+
CREATE USER [mydbogroup] FROM EXTERNAL PROVIDER;
260+
```
272261
3. In the user database add the user representing the Azure AD group, to the **db_owner** fixed database role. For example:
273-
274-
```
275-
276-
ALTER ROLE db_owner ADD MEMBER mydbogroup;
277-
278-
```
262+
```
263+
ALTER ROLE db_owner ADD MEMBER mydbogroup;
264+
```
279265

280266
Now the `mydbogroup` members can centrally manage the database as members of the **db_owner** role.
281267
- When members of this group are removed from the Azure AD group, they automatically loose the dbo permissions for this database.
@@ -284,9 +270,7 @@ Now the `mydbogroup` members can centrally manage the database as members of the
284270
To check if a specific user has the effective dbo permission, have the user execute the following statement:
285271

286272
```
287-
288273
SELECT IS_MEMBER ('db_owner');
289-
290274
```
291275

292276
A return value of 1 indicates the user is a member of the role.
@@ -338,9 +322,7 @@ GO
338322
### D. Transfer ownership of an endpoint to a SQL Server login
339323
The following example transfers ownership of endpoint `CantabSalesServer1` to `JaePak`. Because the endpoint is a server-level securable, the endpoint can only be transferred to a server-level principal.
340324

341-
||
342-
|-|
343-
|**Applies to**: [!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)] through [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)].|
325+
**Applies to**: [!INCLUDE[ssKatmai](../../includes/sskatmai-md.md)] through [!INCLUDE[ssCurrent](../../includes/sscurrent-md.md)].
344326

345327
```
346328
ALTER AUTHORIZATION ON ENDPOINT::CantabSalesServer1 TO JaePak;
@@ -349,13 +331,11 @@ GO
349331

350332
### E. Changing the owner of a table
351333
Each of the following examples changes the owner of the `Sprockets` table in the `Parts` database to the database user `MichikoOsada`.
352-
353334
```
354335
ALTER AUTHORIZATION ON Sprockets TO MichikoOsada;
355336
ALTER AUTHORIZATION ON dbo.Sprockets TO MichikoOsada;
356337
ALTER AUTHORIZATION ON OBJECT::Sprockets TO MichikoOsada;
357338
ALTER AUTHORIZATION ON OBJECT::dbo.Sprockets TO MichikoOsada;
358-
359339
```
360340

361341
### F. Changing the owner of a database
@@ -371,9 +351,7 @@ ALTER AUTHORIZATION ON DATABASE::Parts TO MichikoOsada;
371351
In the following example, an Azure Active Directory administrator for SQL Server in an organization with an active directory named `cqclinic.onmicrosoft.com`, can change the current ownership of a database `targetDB` and make an AAD user `richel@cqclinic.onmicorsoft.com` the new database owner using the following command:
372352

373353
```
374-
375354
ALTER AUTHORIZATION ON database::targetDB TO [rachel@cqclinic.onmicrosoft.com];
376-
377355
```
378356

379357
Note that for Azure AD users the brackets around the user name must be used.

0 commit comments

Comments
 (0)