Events
Get certified in Microsoft Fabric—for free!
19 Nov, 11 pm - 10 Dec, 11 pm
For a limited time, the Microsoft Fabric Community team is offering free DP-600 exam vouchers.
Prepare nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics Analytics Platform System (PDW) SQL analytics endpoint in Microsoft Fabric Warehouse in Microsoft Fabric
Starting with version 18.2.1, Microsoft OLE DB Driver for SQL Server allows OLE DB applications to connect to Azure SQL Database, Azure SQL Managed Instance, Azure Synapse Analytics, and Microsoft Fabric using a federated identity.
Microsoft Entra authentication methods include:
Version 18.3.0 adds support for the following Microsoft Entra authentication methods:
Interactive authentication
Managed identity authentication (only from within an Azure Virtual Machine configured with Managed Identity)
Version 18.5.0 adds support for the following authentication method:
Note
Using the following authentication modes with DataTypeCompatibility
(or its corresponding property) set to 80
is not supported:
To use Microsoft Entra authentication, you must configure your Azure SQL data source. For more information, see Configure and manage Microsoft Entra authentication with Azure SQL.
The following connection string keywords have been introduced to support Microsoft Entra authentication:
Connection string keyword | Connection property | Description |
---|---|---|
Access Token | SSPROP_AUTH_ACCESS_TOKEN |
Specifies an access token to authenticate to Microsoft Entra ID. |
Authentication | SSPROP_AUTH_MODE |
Specifies authentication method to use. |
For more information about the new keywords/properties, see the following pages:
See Encryption and certificate validation for more information.
The driver graphical user interface has been enhanced to allow Microsoft Entra authentication. For more information, see:
This section shows examples of new and existing connection string keywords to be used with IDataInitialize::GetDataSource
and DBPROP_INIT_PROVIDERSTRING
property.
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=SqlPassword;User ID=[username];Password=[password];Use Encryption for Data=Mandatory
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];User ID=[username];Password=[password];Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Server=[server];Database=[database];Authentication=SqlPassword;UID=[username];PWD=[password];Encrypt=Mandatory
Server=[server];Database=[database];UID=[username];PWD=[password];Encrypt=Mandatory
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=ActiveDirectoryIntegrated;Use Encryption for Data=Mandatory
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Integrated Security=SSPI;Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Server=[server];Database=[database];Authentication=ActiveDirectoryIntegrated;Encrypt=Mandatory
Server=[server];Database=[database];Trusted_Connection=yes;Encrypt=Mandatory
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=ActiveDirectoryPassword;User ID=[username];Password=[password];Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Server=[server];Database=[database];Authentication=ActiveDirectoryPassword;UID=[username];PWD=[password];Encrypt=Mandatory
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=ActiveDirectoryIntegrated;Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Server=[server];Database=[database];Authentication=ActiveDirectoryIntegrated;Encrypt=Mandatory
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Access Token=[access token];Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Providing access token through
DBPROP_INIT_PROVIDERSTRING
isn't supported
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=ActiveDirectoryInteractive;User ID=[username];Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Server=[server];Database=[database];Authentication=ActiveDirectoryInteractive;UID=[username];Encrypt=Mandatory
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=ActiveDirectoryMSI;User ID=[Object ID];Use Encryption for Data=Mandatory
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=ActiveDirectoryMSI;Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Server=[server];Database=[database];Authentication=ActiveDirectoryMSI;UID=[Object ID];Encrypt=Mandatory
Server=[server];Database=[database];Authentication=ActiveDirectoryMSI;Encrypt=Mandatory
IDataInitialize::GetDataSource
:
Provider=MSOLEDBSQL19;Data Source=[server];Initial Catalog=[database];Authentication=ActiveDirectoryServicePrincipal;User ID=[Application (client) ID];Password=[Application (client) secret];Use Encryption for Data=Mandatory
DBPROP_INIT_PROVIDERSTRING
:
Server=[server];Database=[database];Authentication=ActiveDirectoryServicePrincipal;UID=[Application (client) ID];PWD=[Application (client) secret];Encrypt=Mandatory
The following samples show the code required to connect to Microsoft Entra ID with connection keywords.
#include <string>
#include <iostream>
#include <msdasc.h>
int main()
{
wchar_t azureServer[] = L"server";
wchar_t azureDatabase[] = L"mydatabase";
wchar_t accessToken[] = L"eyJ0eXAiOi...";
IDBInitialize *pIDBInitialize = nullptr;
IDataInitialize* pIDataInitialize = nullptr;
HRESULT hr = S_OK;
CoInitialize(nullptr);
// Construct the connection string.
std::wstring connString = L"Provider=MSOLEDBSQL19;Data Source=" + std::wstring(azureServer) + L";Initial Catalog=" +
std::wstring(azureDatabase) + L";Access Token=" + accessToken + L";Use Encryption for Data=Mandatory;";
hr = CoCreateInstance(CLSID_MSDAINITIALIZE, nullptr, CLSCTX_INPROC_SERVER,
IID_IDataInitialize, reinterpret_cast<LPVOID*>(&pIDataInitialize));
if (FAILED(hr))
{
std::cout << "Failed to create an IDataInitialize instance." << std::endl;
goto Cleanup;
}
hr = pIDataInitialize->GetDataSource(nullptr, CLSCTX_INPROC_SERVER, connString.c_str(),
IID_IDBInitialize, reinterpret_cast<IUnknown**>(&pIDBInitialize));
if (FAILED(hr))
{
std::cout << "Failed to get data source object." << std::endl;
goto Cleanup;
}
hr = pIDBInitialize->Initialize();
if (FAILED(hr))
{
std::cout << "Failed to establish connection." << std::endl;
goto Cleanup;
}
Cleanup:
if (pIDBInitialize)
{
pIDBInitialize->Uninitialize();
pIDBInitialize->Release();
}
if (pIDataInitialize)
{
pIDataInitialize->Release();
}
CoUninitialize();
}
#include <string>
#include <iostream>
#include <msdasc.h>
int main()
{
wchar_t azureServer[] = L"server";
wchar_t azureDatabase[] = L"mydatabase";
IDBInitialize *pIDBInitialize = nullptr;
IDataInitialize* pIDataInitialize = nullptr;
HRESULT hr = S_OK;
CoInitialize(nullptr);
// Construct the connection string.
std::wstring connString = L"Provider=MSOLEDBSQL19;Data Source=" + std::wstring(azureServer) + L";Initial Catalog=" +
std::wstring(azureDatabase) + L";Authentication=ActiveDirectoryIntegrated;Use Encryption for Data=Mandatory;";
hr = CoCreateInstance(CLSID_MSDAINITIALIZE, nullptr, CLSCTX_INPROC_SERVER,
IID_IDataInitialize, reinterpret_cast<LPVOID*>(&pIDataInitialize));
if (FAILED(hr))
{
std::cout << "Failed to create an IDataInitialize instance." << std::endl;
goto Cleanup;
}
hr = pIDataInitialize->GetDataSource(nullptr, CLSCTX_INPROC_SERVER, connString.c_str(),
IID_IDBInitialize, reinterpret_cast<IUnknown**>(&pIDBInitialize));
if (FAILED(hr))
{
std::cout << "Failed to get data source object." << std::endl;
goto Cleanup;
}
hr = pIDBInitialize->Initialize();
if (FAILED(hr))
{
std::cout << "Failed to establish connection." << std::endl;
goto Cleanup;
}
Cleanup:
if (pIDBInitialize)
{
pIDBInitialize->Uninitialize();
pIDBInitialize->Release();
}
if (pIDataInitialize)
{
pIDataInitialize->Release();
}
CoUninitialize();
}
Authorize access to Microsoft Entra web applications using the OAuth 2.0 code grant flow.
Learn about Microsoft Entra authentication to SQL Server.
Configure driver connections using connection string keywords the OLE DB driver supports.
Events
Get certified in Microsoft Fabric—for free!
19 Nov, 11 pm - 10 Dec, 11 pm
For a limited time, the Microsoft Fabric Community team is offering free DP-600 exam vouchers.
Prepare now