Skip to main content

Azure Active Directory - How to create an application (part 1)

I’m starting a series of blog post that will be about Azure Active Directory (AAD). This blog posts will cover the following topics:

  • How to create an application for AAD
  • How to get access token for Office 365 from a native application (SL,WPF, Store)
  • How to get access token for Office 365 from a web application or Windows Phone 8
  • Multi-factor Authentication 

In this post we will talk about AAD and application over AAD. When we are working with AAD, we can manage users, groups and credentials similar with the Active Directory system that we have on-premises. Both of them are very similar, only the administration UI is a little different.
To be able to access different resources in the name of the user we need to authenticate the user in only one place. In this way, the 3rd parties’ application will not handle the user credentials. This is the most important thing that we should take into account.

This can be done using AAD because we have native support for Single Sign-On. When we are talking about Single Sign-On we should think to an application that don’t require user credentials from user, but it displays a page from WAAD tenant (AAD) where user can enter his own credentials. These page is not handled by the application, only the tenant has control over this page. After the authentication process ends, the application will receive a unique token from tenant that can be used by application to access in the name of the user specific resources for a limited time period.
From portal, we have the option to create to different types of application

  • Web Application
  • Native Client Application

You should know that the Web Application can be used with any application type, because we need to render an HTML page from AAD backend. This can be done in a web application, in a WPF application or in a Windows Phone application.
The native client application can be used with success for the type of application for which we have native support. By native support, we are referring to a library that can be used directly, without having to render a custom HTML page and so (more details in the next post of this series).
In both cases, you should know that you cannot customize the page where user credentials need to be entered. The only think that you can change is the logo. The scope of this limitation is to give the user the confident that the page where he enters his credentials is the real page and not a fake one.
Application
When you create the application on Azure portal, you will see that you have a unique client id. Using this unique client id, your application will be unique identified (we are referring to the application that access AAD and not the one that you want to develop).
Also, you will need to specify the redirect URI. This address will be used for OAuth 2.0 when the redirect is done. Don’t wary if you don’t have a real address. You only need to specify a valid one – http://localhost or http://bing.com should be fine.
The most important think is the “Permissions to other applications” section. Using this section you specify which resources can be accessed using  the token that will be generated for your application.
In this example we want to give access to Office 365 Exchange Online. In this case we will add “Office 365 Exchange Online” in the applications list of this section. For testing purpose, you can set all the permissions to TRUE. Don’t forget to save the changes.
From this moment anybody that will have a token from this application will be able to access the Exchange Account from Office 365.
All this options are valid for Native Client Application. For Web Application, there are some additional options that can be set.
There is a list of keys that can be automatically generated. The key list is useful when you will need to request an access token. You will need to provide this key. Be aware on one thing. The key value is displayed only when you create it. After that moment the key is not displayed anymore. You will be able only to delete it (remove).
Each application had an APP ID URI and a REPLY URL. For testing purpose you can set them to http://localhost/. APP ID URI represent the address of your application. The second one is the address that will be used by AAD to reply to the authentication request.
In the next post we will see what code we need to write to be able to get a token from a Silverlight, Console or Store application.

Comments

Popular posts from this blog

Windows Docker Containers can make WIN32 API calls, use COM and ASP.NET WebForms

After the last post , I received two interesting questions related to Docker and Windows. People were interested if we do Win32 API calls from a Docker container and if there is support for COM. WIN32 Support To test calls to WIN32 API, let’s try to populate SYSTEM_INFO class. [StructLayout(LayoutKind.Sequential)] public struct SYSTEM_INFO { public uint dwOemId; public uint dwPageSize; public uint lpMinimumApplicationAddress; public uint lpMaximumApplicationAddress; public uint dwActiveProcessorMask; public uint dwNumberOfProcessors; public uint dwProcessorType; public uint dwAllocationGranularity; public uint dwProcessorLevel; public uint dwProcessorRevision; } ... [DllImport("kernel32")] static extern void GetSystemInfo(ref SYSTEM_INFO pSI); ... SYSTEM_INFO pSI = new SYSTEM_INFO(

Azure AD and AWS Cognito side-by-side

In the last few weeks, I was involved in multiple opportunities on Microsoft Azure and Amazon, where we had to analyse AWS Cognito, Azure AD and other solutions that are available on the market. I decided to consolidate in one post all features and differences that I identified for both of them that we should need to take into account. Take into account that Azure AD is an identity and access management services well integrated with Microsoft stack. In comparison, AWS Cognito is just a user sign-up, sign-in and access control and nothing more. The focus is not on the main features, is more on small things that can make a difference when you want to decide where we want to store and manage our users.  This information might be useful in the future when we need to decide where we want to keep and manage our users.  Feature Azure AD (B2C, B2C) AWS Cognito Access token lifetime Default 1h – the value is configurable 1h – cannot be modified

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine: threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration: TeamCity .NET 4.51 EF 6.0.2 VS2013 It see