Andrei Kolesnikovich
Andrei Kolesnikovich

Reputation: 13

Check Office365 session

Is there any solutions to understand from my MVC application that user already signed in into Office365?

Currently I'm using the code below to authenticate to my MVC application:

var authContext = new AuthenticationContext("https://login.windows.net/MyTenantId");
var authResult = authContext.AcquireToken("https://MyTenantId/AppWebApi", "ClientId", new Uri("redirect uri"));

By this code user is suggested to enter his credentials to sign in into Azure Active Directory. And it works fine, but it doesn't see that user already signed in to Office365 and work with Word, for example.

Upvotes: 0

Views: 69

Answers (1)

vibronet
vibronet

Reputation: 7394

The code you wrote there does not work in a web application. It might work while you are hitting localhost, but as soon as you deploy your web app to an actual server it will not be able to pop out the dialog. Did you get that code form some sample? Could you point me to that? This is already the 2nd question containing the same error in 2 days, after 2 or 3 years of the library being available.

Back to your question.

How did the user sign in your application? If you would have used AAD to handle web sign on, like in this sample, you would know upfront (and the answer would be always 'yes', just for the fact that he/she'd need to in order to have access to your application). If you are using a different sign on system, there are techniques for finding out if a user is signed in without showing any UX, but they are pretty advanced (requiring the use of a hidden frame and special request parameters) and before digging deeper in that I think it would be useful to know what your scenario requires. Do you need a token, or do you simply need to know if the user is already signed in in O365?

Upvotes: 1

Related Questions