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
Note: Run this project on a machine joined to a domain that is federated with Azure Active Directory. A contained database user representing your Azure AD principal, or one of the groups, you belong to, must exist in the database and must have the CONNECT permission.
2
+
Note: Run this project on a machine joined to a domain that is federated with Microsoft Entra. A contained database user representing your Microsoft Entra ID principal, or one of the groups, you belong to, must exist in the database and must have the CONNECT permission.
3
3
4
4
1. Before building and running the Integrated project:
5
5
6
6
+ In Program.cs, locate the following lines of code and replace the server/database name with your server/database name.
7
7
```
8
-
builder["Data Source"] = "aad-managed-demo.database.windows.net "; // replace 'aad-managed-demo' with your server name
8
+
builder["Data Source"] = "<server name>.database.windows.net "; // replace '<server name>' with your server name
9
9
builder["Initial Catalog"] = "demo"; // replace with your database name
10
10
```
11
11
12
-
2. The builder["Authentication"] method must be set to SqlAuthenticationMethod.ActiveDirectoryIntegrated;
13
-
![screenshot of visual studio showing builder fields to change] (/samples/features/security/azure-active-directory-auth/img/vs-authentication-method-integrated.png)
12
+
2. The `builder["Authentication"]` method must be set to `SqlAuthenticationMethod.ActiveDirectoryIntegrated`;
14
13
15
-
3. Running this project on a machine joined to a domain that is federated with Azure Active Directory will automatically use your Windows credentials and no password is required. The execution window will indicate a successful connection to the database followed by “Please press any key to stop”:
16
-
![screenshot of application after successful authentication- "press any key to stop"] (/samples/features/security/azure-active-directory-auth/img/integrated-press-any-key-to-stop.png)
14
+

15
+
16
+
3. Running this project on a machine joined to a domain that is federated with Microsoft Entra will automatically use your Windows credentials and no password is required. The execution window will indicate a successful connection to the database followed by “Please press any key to stop”:
17
+

Copy file name to clipboardExpand all lines: samples/features/security/azure-active-directory-auth/password/README.md
+7-10Lines changed: 7 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,20 +3,17 @@
3
3
**Before building and running the Password project**:
4
4
1. In Program.cs, locate the following lines of code and replace the server/database name with your server/database name.
5
5
```
6
-
builder["Data Source"] = "aad-managed-demo.database.windows.net "; // replace 'aad-managed-demo' with your server name
6
+
builder["Data Source"] = "<servername>.database.windows.net "; // replace '<servername>' with your server name
7
7
builder["Initial Catalog"] = "demo"; // replace with your database name
8
8
```
9
-
2. Locate the following line of code and replace username, with the name of the Azure AD user you want to connect as.
9
+
2. Locate the following line of code and replace username, with the name of the Microsoft Entra ID user you want to connect as.
10
10
```
11
-
string username = "bob@cqclinic.onmicrosoft.com"; // replace with your username
11
+
string username = "bob@contoso.com"; // replace with your username
12
12
```
13
-
Note: A contained user database must exist and a contained database user representing the specified Azure AD user or one of the groups, the specified Azure AD user belongs to, must exist in the database and must have the CONNECT permission (except for AAD server admin or group)
13
+
Note: A contained user database must exist and a contained database user representing the specified Microsoft Entra ID user or one of the groups, the specified Microsoft Entra ID user belongs to, must exist in the database and must have the CONNECT permission (except for AAD server admin or group)
14
14
15
-
Please note that
16
-
builder["Authentication"] method is set to SqlAuthenticationMethod.ActiveDirectoryPassword.
15
+
Please note that the `builder["Authentication"]` method is set to `SqlAuthenticationMethod.ActiveDirectoryPassword`.
17
16
18
-
![screenshot of visual studio showing builder fields to change] (/samples/features/security/azure-active-directory-auth/img/vs-authentication-method-password.png)
17
+
When running this program an execution window a prompt for the Microsoft Entra ID password request for user bob@cqclinic.onmicrosoft.com will appear. Once the password is entered the message should indicate a successful connection to the database followed by “Please press any key to stop”:
19
18
20
-
When running this program an execution window a prompt for the Azure AD password request for user bob@cqclinic.onmicrosoft.com will appear. Once the password is entered the message should indicate a successful connection to the database followed by “Please press any key to stop”:
21
-
22
-
![screenshot of application after successful authentication- "press any key to stop"] (/samples/features/security/azure-active-directory-auth/img/pwd-press-any-key-to-stop.png)
19
+

Copy file name to clipboardExpand all lines: samples/features/security/azure-active-directory-auth/readme.md
+6-7Lines changed: 6 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,16 +35,15 @@ To run this sample, you need the following prerequisites:
35
35
+ ADALSQL.DLL enables applications to authenticate to Microsoft Azure SQL Database using Azure Active Directory. The ADALSQL.DLL is not installed with Visual Studio so download the DLL at http://www.microsoft.com/en-us/download/details.aspx?id=48742
36
36
+ ADALSQL.DLL is automatically downloaded with Visual Studio 2015 Update 2, SQL Server Management Studio, and the newest version of SQL Server Data tools
37
37
38
-
1. Create Azure Active Directory (AD), or federate your domain with existing Azure AD
39
-
This allows either to use managed or federated accounts associated with a specific Azure AD
40
-
2. Create Azure AD administrator for Azure SQL DB using Azure portal, PowerShell command or Rest API
41
-
3. With help from T-SQL query interface (i.e. SSMS query editor), using Azure AD admin credentials for SQL DB & SQL DW, create an Azure AD user in a designated database. The database user represents your Azure AD principal (or one of the groups you belong to) and must exist in the database having CONNECT permission prior to executing a connection attempt
38
+
1. Create Microsoft Entra tenant (formerly known as Azure Active Directory), or federate your domain with existing Microsoft Entra ID. This allows either to use managed or federated accounts associated with a specific Microsoft Entra ID.
39
+
2. Create Microsoft Entra ID administrator for Azure SQL Database using the Azure portal, PowerShell command, or Rest API.
40
+
3. With help from T-SQL query interface (i.e. SSMS query editor), using Microsoft Entra ID admin credentials for Azure SQL Database and dedicated SQL pools in Azure Synapse, create an Microsoft Entra ID user in a designated database. The database user represents your Microsoft Entra ID principal (or one of the groups you belong to) and must exist in the database having CONNECT permission prior to executing a connection attempt.
42
41
43
42
44
43
**Other Prerequisites**
45
44
46
-
1. For Azure AD integrated authentication a computer joined to a domain that is federated with Azure Active Directory is required
47
-
2. An existing database created before a connection attempt is required. The database can be created using credentials for SQL administrator, or Azure AD SQL administrator
45
+
1. For Microsoft Entra ID integrated authentication a computer joined to a domain that is federated with Azure Active Directory is required.
46
+
2. An existing database created before a connection attempt is required. The database can be created using credentials for SQL administrator, or Microsoft Entra SQL administrator.
48
47
49
48
<aname=run-this-sample></a>
50
49
@@ -62,7 +61,7 @@ To run this sample, you need the following prerequisites:
62
61
63
62
## Sample details
64
63
65
-
This demo provides a simple tool for exploring Azure Active Directory authentication to Azure SQL DB or Azure SQL DW.
64
+
This demo provides a simple tool for exploring Azure Active Directory authentication to Azure SQL Database and dedicated SQL pools in Azure Synapse.
66
65
67
66
Azure Active Directory authentication with Azure SQL Database V12 supports the following authentication methods:
Copy file name to clipboardExpand all lines: samples/features/security/azure-active-directory-auth/token/README.md
+19-22Lines changed: 19 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,39 +8,38 @@
8
8
9
9
## About this sample
10
10
11
-
The Token project contains a simple console application that connects to Azure SQL database using a self-signed certificate.
11
+
The Token project contains a simple console application that connects to Azure SQL Database using a self-signed certificate.
12
12
13
13
**Software prerequisites:**
14
14
15
15
1. The `makecert.exe` utility, which is included in the Windows SDK
16
16
+ It is sometimes included in Visual Studio installations (depending on the selections made during installation). A search of your machine for `makecert.exe` would provide verification that the Windows SDK was installed.
17
-
+ If the Windows SDK was not installed, you may [download it here](http://msdn.microsoft.com/en-US/windows/desktop/aa904949)
17
+
+ If the Windows SDK was not installed, you may [download it here](https://learn.microsoft.com/windows/apps/windows-app-sdk/downloads)
18
18
+ You can learn more about the `makecert.exe` [utility here](https://msdn.microsoft.com/library/windows/desktop/aa386968.aspx)
19
19
2. PowerShell with Azure Active Directory Module
20
-
+ To download the latest PowerShell version [see this page](https://azure.microsoft.com/en-us/documentation/articles/powershell-install-configure/#Install)
21
-
+ [Install the Azure AD PowerShell Module](https://msdn.microsoft.com/en-us/library/azure/jj151815.aspx), if it is not already installed in your client machine.
20
+
+ To download the latest PowerShell version [see this page](https://learn.microsoft.com/powershell/azure/install-azure-powershell)
21
+
+ [Install the Microsoft Entra ID PowerShell Module](https://learn.microsoft.com/powershell/entra-powershell/installation), if it is not already installed in your client machine.
22
22
23
23
<aname=run-this-sample></a>
24
24
## Run this sample
25
25
26
-
1. Create an application account in Azure AD for your service.
26
+
1. Create an application account in Microsoft Entra ID for your service.
27
27
- Sign in to the Azure management portal.
28
28
- Click on Azure Active Directory in the left hand navigation
29
29
- Click the directory tenant where you wish to register the sample application. This must be the same directory that is associated with your database (the server hosting your database).
30
30
- Click the Applications tab
31
31
- In the drawer, click Add.
32
32
- Click "Add an application my organization is developing".
33
33
- Enter mytokentest as a friendly name for the application, select "Web Application and/or Web API", and click next.
34
-
- Assuming this application is a daemon/service and not a web application, it doesn't have a sign-in URL or app ID URI. For these two fields, enter http://mytokentest
35
-
- While still in the Azure portal, click the Configure tab of your application.
36
-
- Find the Client ID value and copy it into a text editor, you will need this later when configuring your application ( i.e. a4bbfe26-dbaa-4fec-8ef5-223d229f647d /see the snapshot below/)
37
-

34
+
- Assuming this application is a daemon/service and not a web application, it doesn't have a sign-in URL or app ID URI. For these two fields, enter `http://mytokentest`
35
+
- While still in the Azure portal, select Configure in your application.
36
+
- Find the Client ID value and copy it into a text editor, you will need this later when configuring your application
38
37
39
-
2. Logon to your Azure SQL Server’s user database as an Azure AD admin and using a T-SQL command provision a contained database user for your application principal:
38
+
2. Logon to your Azure SQL Server’s user database as an Microsoft Entra ID admin and using a T-SQL command provision a contained database user for your application principal:
40
39
```sql
41
40
CREATE USER [mytokentest] FROM EXTERNAL PROVIDER
42
41
```
43
-
- [See this link](https://azure.microsoft.com/en-us/documentation/articles/sql-database-aad-authentication/) for more details on how to create an Azure Ad admin and a contained database user.
42
+
- [See this link](https://azure.microsoft.com/documentation/articles/sql-database-aad-authentication/) for more details on how to create an Microsoft Entra ID admin and a contained database user.
44
43
45
44
3. On the machine you are going to run the project on, generate and install a self-signed certificate.
46
45
- To complete this step, you will need to use `Makecert.exe`
@@ -53,10 +52,10 @@ The Token project contains a simple console application that connects to Azure S
4. Add the certificate as a key for the application you created in Azure AD.
57
-
- Click the Microsoft Azure Active Directory Module for Windows PowerShell shortcut on desktop to open a Windows PowerShell workspace that has the Azure AD cmdlets.
55
+
4. Add the certificate as a key for the application you created in Microsoft Entra ID.
56
+
- Click the Microsoft Azure Active Directory Module for Windows PowerShell shortcut on desktop to open a Windows PowerShell workspace that has the Microsoft Entra ID cmdlets.
58
57
- Copy the following code snippet to a text editor.
59
-
- `connect-msolservice` will ask for you Azure AD credentials. Please be sure to use credentials that are part of Azure AD global admin to connect and to proceed with the scripts below.
58
+
- `connect-msolservice` will ask for you Microsoft Entra ID credentials. Please be sure to use credentials that are part of Microsoft Entra ID global admin to connect and to proceed with the scripts below.
60
59
```
61
60
connect-msolservice
62
61
@@ -74,23 +73,21 @@ The Token project contains a simple console application that connects to Azure S
74
73
75
74
5. Configure the certificate and your application account in the *app.config* file in the project.
76
75
+ In Visual Studio, open *app.config* in the Solution Explorer
- Find the app key `ida:Tenant` and replace the value with your AAD tenant name (your AAD domain)
79
77
- Find the app key `ida:ClientID` and replace the value with the Client ID for the application registration from the Azure Portal (the value from step 1).
80
78
- Find the app key `ida:Cert_Name` and replace the value with the subject name (CN) of the self-signed certificate you created
81
79
- For example:
82
80
```csharp
83
-
<add key="ida:Tenant" value="cqclinic.onmicrosoft.com" /> //this is the AAD domain
84
-
<add key="ida:ClientId" value="a4bbfe26-dbaa-4fec-8ef5-223d229f647d"/> //this is the Client ID
81
+
<add key="ida:Tenant" value="<tenant name>" /> //this is the domain
82
+
<add key="ida:ClientId" value="<client id>"/> //this is the Client ID
85
83
<add key="ida:CertName" value="CN=mytokentestCert"/> //this is the Cert_name use by makecert.exe
86
84
```
87
85
+ In Visual Studio, open *Program.cs* in the Solution Explorer
88
-

86
+

89
87
- Make the following changes:
90
88
```csharp
91
-
builder["Data Source"] = "aad-managed-demo.database.windows.net"; // replace with your server name
89
+
builder["Data Source"] = "<server name>.database.windows.net"; // replace <server name> with your server name
92
90
builder["Initial Catalog"] = "demo"; // replace with your database name
93
91
```
94
-
6. Run the demo. (Click *Run* or press *F5*)
95
-
+ A successful authorization should result in a message that states "Connected to the database" similar to the following:
+ A successful authorization should result in a message that includes "The access token obtained" and states "Connected to the database" and "Please press any key to stop".
0 commit comments