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: docs/relational-databases/security/authentication-access/azure-ad-authentication-sql-server-linked-server.md
+21-16Lines changed: 21 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,29 @@
1
1
---
2
-
title: "Linked server for SQL Server with Microsoft Entra authentication"
2
+
title: "Linked Server for SQL Server with Microsoft Entra Authentication"
3
3
description: Learn about how to use linked server for SQL Server with Microsoft Entra authentication
# Linked server for SQL Server with Microsoft Entra authentication
16
17
17
-
[!INCLUDE [SQL Server 2022](../../../includes/applies-to-version/sqlserver2022.md)]
18
+
[!INCLUDE [SQL Server 2022 and later](../../../includes/applies-to-version/sqlserver2022-and-later.md)]
18
19
19
-
[Linked servers](../../linked-servers/linked-servers-database-engine.md) can now be configured using [authentication](azure-ad-authentication-sql-server-overview.md) with Microsoft Entra ID ([formerly Azure Active Directory](/entra/fundamentals/new-name)), and it supports two mechanisms for providing credentials:
20
+
[Linked servers](../../linked-servers/linked-servers-database-engine.md) can now be configured using [authentication](azure-ad-authentication-sql-server-overview.md) with Microsoft Entra ID ([formerly Azure Active Directory](/entra/fundamentals/new-name)), and it supports three mechanisms for providing credentials:
20
21
21
22
- Password
22
23
- Access token
24
+
- Managed identity (SQL Server 2025 and later)
25
+
26
+
This article covers password and access token authentication. For SQL Server 2025 and later, you can also use managed identity authentication for linked servers. For more information, see [Configure managed identity for linked servers](../../../sql-server/azure-arc/managed-identity-support-linked-server.md).
23
27
24
28
This article assumes there are two SQL Server instances (`S1` and `S2`). Both have been configured to support Microsoft Entra authentication, and they trust each other's SSL/TLS certificate. The examples in this article are executed on server `S1` to create a linked server to server `S2`.
25
29
@@ -28,10 +32,10 @@ This article assumes there are two SQL Server instances (`S1` and `S2`). Both ha
28
32
- Fully operational Microsoft Entra authentication for SQL Server. For more information, see [Microsoft Entra authentication for SQL Server](azure-ad-authentication-sql-server-overview.md) and [Tutorial: Set up Microsoft Entra authentication for SQL Server](azure-ad-authentication-sql-server-setup-tutorial.md).
29
33
-[SQL Server Management Studio (SSMS)](/ssms/install/install) version 18.0 or higher.
30
34
31
-
> [!NOTE]
35
+
> [!NOTE]
32
36
> The subject name of the SSL/TLS certificate used by `S2` must match the server name provided in the [`provstr`](../../system-stored-procedures/sp-addlinkedserver-transact-sql.md) attribute. This should either be the Fully Qualified Domain Name (**FQDN**) or **hostname** of `S2`.
## Linked server configurations for Microsoft Entra authentication
37
41
@@ -54,7 +58,7 @@ For password authentication, using `Authentication=ActiveDirectoryPassword` in t
54
58
-**Provider string**: `Server=<fqdn of S2>;Authentication=ActiveDirectoryPassword`.
55
59
-**Catalog**: leave empty.
56
60
57
-
:::image type="content" source="media/create-linked-server-with-password-authentication.png" alt-text="Screenshot of creating linked server with password authentication":::
61
+
:::image type="content" source="media/create-linked-server-with-password-authentication.png" alt-text="Screenshot of creating linked server with password authentication." lightbox="media/create-linked-server-with-password-authentication.png":::
58
62
59
63
1. Select the **Security** tab.
60
64
1. Select **Add**.
@@ -65,13 +69,13 @@ For password authentication, using `Authentication=ActiveDirectoryPassword` in t
65
69
-**For a login not defined in the list above, connections will**: `Not be made`
66
70
1. Select **OK**.
67
71
68
-
:::image type="content" source="media/linked-server-add-security.png" alt-text="Screenshot of setting security for linked server":::
72
+
:::image type="content" source="media/linked-server-add-security.png" alt-text="Screenshot of setting security for linked server." lightbox="media/linked-server-add-security.png":::
69
73
70
74
### Linked server configuration using access token authentication
71
75
72
76
For access token authentication, the linked server is created with `AccessToken=%s` in the **Provider string**. A linked server login is created to map each login in `S1` to a [Microsoft Entra application](/azure/azure-sql/database/authentication-aad-service-principal), which has been granted login permissions to `S2`. The application must have a secret assigned to it, which will be used by `S1` to generate the access token. A secret can be created by navigating to the [Azure portal](https://portal.azure.com) > **Microsoft Entra ID** > **App registrations** > `YourApplication` > **Certificates & secrets** > **New client secret**.
73
77
74
-
:::image type="content" source="media/application-new-client-secret.png" alt-text="Screenshot of creating a new client secret for an application in the Azure portal":::
78
+
:::image type="content" source="media/application-new-client-secret.png" alt-text="Screenshot of creating a new client secret for an application in the Azure portal." lightbox="media/application-new-client-secret.png":::
75
79
76
80
1. In SSMS, connect to `S1` and expand **Server Objects** in the **Object Explorer** window.
77
81
1. Right-click **Linked Servers** and select **New Linked Server**.
@@ -84,7 +88,7 @@ For access token authentication, the linked server is created with `AccessToken=
84
88
-**Provider string**: `Server=<fqdn of S2>;AccessToken=%s`.
85
89
-**Catalog**: leave empty.
86
90
87
-
:::image type="content" source="media/create-linked-server-with-access-token-authentication.png" alt-text="Screenshot of creating linked server with access token authentication":::
91
+
:::image type="content" source="media/create-linked-server-with-access-token-authentication.png" alt-text="Screenshot of creating linked server with access token authentication." lightbox="media/create-linked-server-with-access-token-authentication.png":::
88
92
89
93
1. Select the **Security** tab.
90
94
1. Select **Add**.
@@ -95,8 +99,9 @@ For access token authentication, the linked server is created with `AccessToken=
95
99
-**For a login not defined in the list above, connections will**: `Not be made`
96
100
1. Select **OK**.
97
101
98
-
## See also
102
+
## Related content
99
103
100
-
-[Connect SQL Server to Azure Arc](../../../sql-server/azure-arc/connect.md)
104
+
-[Configure managed identity for linked servers](../../../sql-server/azure-arc/managed-identity-support-linked-server.md)
105
+
-[Connect your SQL Server to Azure Arc](../../../sql-server/azure-arc/connect.md)
101
106
-[Microsoft Entra authentication for SQL Server](azure-ad-authentication-sql-server-overview.md)
102
-
-[Tutorial: Set up Microsoft Entra authentication for SQL Server](azure-ad-authentication-sql-server-setup-tutorial.md)
107
+
-[Tutorial: Set up Microsoft Entra authentication for SQL Server with app registration](azure-ad-authentication-sql-server-setup-tutorial.md)
@@ -61,7 +61,7 @@ The unique programmatic identifier (PROGID) of the OLE DB provider that correspo
61
61
62
62
- Starting with [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], `MSOLEDBSQL` uses Microsoft OLE DB Driver version 19, which adds support for [TDS 8.0](../security/networking/tds-8.md). However, this driver introduces a breaking change. You must now specify the `encrypt` parameter. Use `encrypt` to define whether or not encryption is mandatory. You must provide a valid CA-signed certificate to encrypt your connection to another SQL Server instance, or assign `encrypt=optional` in the *@provstr* argument. If you can't modify the linked server configuration, enable trace flag 17600 to maintain OLE DB version 18 behavior and defaults.
63
63
64
-
For details about encryption properties, review [Major version differences](../../connect/oledb/major-version-differences.md).
64
+
For details about encryption properties, review [Major version differences](../../connect/oledb/major-version-differences.md).
@@ -132,13 +132,13 @@ The following table shows the ways that a linked server can be set up for data s
132
132
|[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]|[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] Native Client OLE DB Provider |[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] <sup>1</sup> (default) ||||||
133
133
|[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]|[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] Native Client OLE DB Provider ||`SQLNCLI`| Network name of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] (for default instance) ||| Database name (optional) |
134
134
|[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]|[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] Native Client OLE DB Provider ||`SQLNCLI`|*servername*\\*instancename* (for specific instance) ||| Database name (optional) |
135
-
| Oracle, version 8 and later | Oracle Provider for OLE DB | Any |`OraOLEDB.Oracle`| Alias for the Oracle database ||||
136
-
| Access/Jet | Microsoft OLE DB Provider for Jet | Any |`Microsoft.Jet.OLEDB.4.0`| Full path of Jet database file ||||
137
-
| ODBC data source | Microsoft OLE DB Provider for ODBC | Any |`MSDASQL`| System DSN of ODBC data source ||||
138
-
| ODBC data source |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for ODBC | Any |`MSDASQL`||| ODBC connection string ||
139
-
| File system |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for Indexing Service | Any |`MSIDXS`| Indexing Service catalog name ||||
140
-
|[!INCLUDE [msCoName](../../includes/msconame-md.md)] Excel Spreadsheet |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for Jet | Any |`Microsoft.Jet.OLEDB.4.0`| Full path of Excel file || Excel 5.0 ||
141
-
| IBM Db2 Database |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for DB2 | Any |`DB2OLEDB`||| See [!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for DB2 documentation. | Catalog name of DB2 database |
135
+
| Oracle, version 8 and later | Oracle Provider for OLE DB | Any <sup>2</sup> |`OraOLEDB.Oracle`| Alias for the Oracle database ||||
136
+
| Access/Jet | Microsoft OLE DB Provider for Jet | Any <sup>2</sup> |`Microsoft.Jet.OLEDB.4.0`| Full path of Jet database file ||||
137
+
| ODBC data source | Microsoft OLE DB Provider for ODBC | Any <sup>2</sup> |`MSDASQL`| System DSN of ODBC data source ||||
138
+
| ODBC data source |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for ODBC | Any <sup>2</sup> |`MSDASQL`||| ODBC connection string ||
139
+
| File system |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for Indexing Service | Any <sup>2</sup> |`MSIDXS`| Indexing Service catalog name ||||
140
+
|[!INCLUDE [msCoName](../../includes/msconame-md.md)] Excel Spreadsheet |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for Jet | Any <sup>2</sup> |`Microsoft.Jet.OLEDB.4.0`| Full path of Excel file || Excel 5.0 ||
141
+
| IBM Db2 Database |[!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for DB2 | Any <sup>2</sup> |`DB2OLEDB`||| See [!INCLUDE [msCoName](../../includes/msconame-md.md)] OLE DB Provider for DB2 documentation. | Catalog name of DB2 database |
142
142
143
143
<sup>1</sup> This way of setting up a linked server forces the name of the linked server to be the same as the network name of the remote instance of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. Use *@datasrc* to specify the server.
144
144
@@ -158,6 +158,21 @@ The stored procedure `sp_addlinkedserver` can't be executed within a user-define
158
158
> [!IMPORTANT]
159
159
> When a linked server is created by using `sp_addlinkedserver`, a default self-mapping is added for all local logins. For non-[!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] providers, [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] Authenticated logins might be able to gain access to the provider under the [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)] service account. Administrators should consider using `sp_droplinkedsrvlogin <linkedserver_name>, NULL` to remove the global mapping.
160
160
161
+
## Managed identity authentication for SQL Server 2025
162
+
163
+
**Applies to**: [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] and later versions
164
+
165
+
[!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] introduces support for managed identity authentication when creating linked servers between SQL Server instances. This feature allows SQL Server instances running on Azure Virtual Machines or Azure Arc-enabled servers to use managed identities for secure, credential-free authentication to other SQL Server instances.
166
+
167
+
Managed identity authentication is supported when the following requirements are met:
168
+
169
+
- The source SQL Server instance is running on an Azure Virtual Machine with a system-assigned or user-assigned managed identity enabled, or on an Azure Arc-enabled server with a system-assigned managed identity configured.
170
+
- The destination is another SQL Server instance with Microsoft Entra authentication configured.
171
+
- A login matching the source server's name has been created on the destination SQL Server instance from an external provider.
172
+
- The connection uses the Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL) with `Authentication=ActiveDirectoryMSI` in the provider string.
173
+
174
+
For detailed configuration steps, see [Configure managed identity for linked servers](../../sql-server/azure-arc/managed-identity-support-linked-server.md).
175
+
161
176
## Permissions
162
177
163
178
The `sp_addlinkedserver` statement requires the `ALTER ANY LINKED SERVER` permission. (The [!INCLUDE [ssManStudioFull](../../includes/ssmanstudiofull-md.md)]**New Linked Server** dialog box is implemented in a way that requires membership in the **sysadmin** fixed server role.)
@@ -186,7 +201,7 @@ EXECUTE sp_addlinkedserver
186
201
@datasrc = N'S1\instance1';
187
202
```
188
203
189
-
The following example creates the linked server `S1_instance1` but uses the Microsoft OLE DB Driver Version 19 in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], with the `encrypt=optional` parameter:
204
+
The following example creates the linked server `S1_instance1` but uses the Microsoft OLE DB Driver Version 19 in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], with the `encrypt=optional` parameter:
190
205
191
206
```sql
192
207
EXECUTE sp_addlinkedserver
@@ -197,7 +212,7 @@ EXECUTE sp_addlinkedserver
197
212
@datasrc = N'S1\instance1';
198
213
```
199
214
200
-
The following example creates the linked server `S1_instance1` using the Microsoft OLE DB Driver Version 19 in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], with the `encrypt=mandatory` parameter. This option requires a valid certificate, the self-signed certificate is not accepted.
215
+
The following example creates the linked server `S1_instance1` using the Microsoft OLE DB Driver Version 19 in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], with the `encrypt=mandatory` parameter. This option requires a valid certificate. The self-signed certificate isn't accepted.
201
216
202
217
```sql
203
218
EXECUTE sp_addlinkedserver
@@ -208,7 +223,7 @@ EXECUTE sp_addlinkedserver
208
223
@datasrc = N'S1\instance1';
209
224
```
210
225
211
-
The following example creates the linked server `S1_instance1` using the Microsoft OLE DB Driver Version 19 in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], with `encrypt=mandatory` and `trustservercertificate=yes`. Because **Trust Server Certificate** is set to `yes`, self-signed certificates are accepted.
226
+
The following example creates the linked server `S1_instance1` using the Microsoft OLE DB Driver Version 19 in [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)], with `encrypt=mandatory` and `trustservercertificate=yes`. Because **Trust Server Certificate** is set to `yes`, self-signed certificates are accepted.
212
227
213
228
```sql
214
229
EXECUTE sp_addlinkedserver
@@ -476,6 +491,66 @@ EXECUTE sp_addlinkedserver
476
491
477
492
For more information, see [Microsoft OLE DB Driver for SQL Server (MSOLEDBSQL) (recommended)](../../connect/oledb/oledb-driver-for-sql-server.md#1-microsoft-ole-db-driver-for-sql-server-msoledbsql-recommended).
478
493
494
+
### K. Create a linked server with managed identity authentication for SQL Server 2025
495
+
496
+
**Applies to**: [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] and later versions
497
+
498
+
The following example creates a linked server from a source [!INCLUDE [sssql25-md](../../includes/sssql25-md.md)] instance to a destination SQL Server instance using managed identity authentication. This scenario requires that the source SQL Server instance is running on an Azure Virtual Machine or Azure Arc-enabled server with a managed identity enabled, and that the destination SQL Server has Microsoft Entra authentication configured.
499
+
500
+
Before creating the linked server on the source, you must create a login on the destination SQL Server that matches the source server's name:
501
+
502
+
```sql
503
+
-- Run on the destination SQL Server instance
504
+
USE [master];
505
+
GO
506
+
507
+
CREATE LOGIN [SourceServerName]
508
+
FROM EXTERNAL PROVIDER;
509
+
GO
510
+
511
+
ALTER SERVER ROLE [sysadmin] ADD MEMBER [SourceServerName];
512
+
GO
513
+
```
514
+
515
+
On the source SQL Server, create the linked server using the Microsoft OLE DB Driver for SQL Server with `ActiveDirectoryMSI` authentication:
For complete configuration details including managed identity setup, Microsoft Entra authentication configuration, and permissions, see [Configure managed identity for linked servers](../../sql-server/azure-arc/managed-identity-support-linked-server.md).
0 commit comments