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

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

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.51EF 6.0.2VS2013
It seems that there …

Run native .NET application in Docker (.NET Framework 4.6.2)

Scope
The main scope of this post is to see how we can run a legacy application written in .NET Framework in Docker.

Context
First of all, let’s define what is a legacy application in our context. By a legacy application we understand an application that runs .NET Framework 3.5 or higher in a production environment where we don’t have any more the people or documentation that would help us to understand what is happening behind the scene.
In this scenarios, you might want to migrate the current solution from a standard environment to Docker. There are many advantages for such a migration, like:

Continuous DeploymentTestingIsolationSecurity at container levelVersioning ControlEnvironment Standardization
Until now, we didn’t had the possibility to run a .NET application in Docker. With .NET Core, there was support for .NET Core in Docker, but migration from a full .NET framework to .NET Core can be costly and even impossible. Not only because of lack of features, but also because once you…