Asked by:
Implement AAD Authentication in existing ASP.net (.aspx) projects

Question
-
User1550255994 posted
I need to implement AAD authentication in existing aspx project, can someone help by providing code snippet and steps to implement it.
Thursday, February 21, 2019 1:05 PM
All replies
-
User753101303 posted
Hi,
Which version of VS are you using ? You could create a new project with https://docs.microsoft.com/en-us/aspnet/visual-studio/overview/2013/creating-web-projects-in-visual-studio#organizational-account-authentication-options to check it works.
With VS 2017 (and apparently 2015 ?) you have also https://docs.microsoft.com/en-us/azure/active-directory/develop/vs-active-directory-add-connected-service (which links also to manual steps described at https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-v1-aspnet-webapp)
You'll have to adjust a bit for Web Forms but it should be very similar. I'll perhaps give it a try as I'll need to document that as well for our own internal needs...Thursday, February 21, 2019 1:32 PM -
User475983607 posted
I need to implement AAD authentication in existing aspx project, can someone help by providing code snippet and steps to implement it.
Start by reading the Azure Active Directory documentation as you need to pick an approach that best fits your application and application requirements,
https://docs.microsoft.com/en-us/azure/active-directory/
I believe the common approach is OAuth.
https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
Thursday, February 21, 2019 1:39 PM -
User1550255994 posted
Hi,
I am using VS 2015, my project does not follow MVC architectureThursday, February 21, 2019 1:55 PM -
User475983607 posted
I am using VS 2015, my project does not follow MVC architectureThe examples provided by PatriceSc are OWIN (Open Web Interface for .NET) middleware APIs. The setup for ASP.NET MVC is the same as ASP.NET Web Forms. Implementation is also similar and should not be a issue.
The first step is taking the time to go through the Azure Active Directory documentation. I'm pretty sure you'll use the OAuth protocol. You'll want to spend time learning OAuth too. I would build a few basic test projects before integrating into the main project. This will allow you to focus on learning the technology while not worrying a about integrating into an existing project,
Once you have a good understanding of the new technology, do an analysis on the Web Forms App to figure out how to best integrate. Your demo projects will become a crutch that you can lean on for testing.
Thursday, February 21, 2019 3:22 PM -
User283571144 posted
Hi Mohit Jaiswal,
I need to implement AAD authentication in existing aspx project, can someone help by providing code snippet and steps to implement it.Could you please tell me which kinds of the authentication mode you have selected when you create the project? Individual User Account? Or else?
If you don't select the Individual User Account, you should firstly add own authentication in your project.
Then you could use openid connect to add the AAD Authentication.
If you have use the asp.net identity(Select Individual User Account), then you could follow below article to implement AAD Authentication easily.
Best Regards,
Brando
Friday, February 22, 2019 2:05 AM