How to control login flow in ADAL AuthenticationContext?

Using the ADAL library to get the token for WAAD, I would like to know how I can get more control over the input stream.

var ac = new AuthenticationContext("https://login.windows.net/" + ActiveDirectoryTenantId);
AuthenticationInfo = ac.AcquireToken(
                         resource: "https://management.core.windows.net/",
                         clientId: "1950a258-227b-4e31-a9cf-717495945fc2",
                         redirectUri: new Uri("urn:ietf:wg:oauth:2.0:oob"));

The user will be prompted to log in. For me it is through Live Id, for my client computer it is through an organizational account, and there is no way to switch between them. It seems that it is controlled by how / which current sessions that the computer could start have already entered the azure.

Can I do something in an AcquireToken call to control this? It would be better if I could initiate a normal flow when people enter Azure, where they can choose whether there will be a live identifier or organizational login.

I tried this:

ac.AcquireToken("https://management.core.windows.net/",
                    "1950a258-227b-4e31-a9cf-717495945fc2",
                    new Uri("urn:ietf:wg:oauth:2.0:oob"), PromptBehavior.Always,"wtrealm=urn:federation:MicrosoftOnline");

no luck.

+4
1

, , , .

// ID for site to pass to enable EBD (email-based differentiation)
// This gets passed in the call to get the azure branding on the
// login window. Also adding popup flag to handle overly large login windows.
internal const string EnableEbdMagicCookie = "site_id=501358&display=popup";

private void ClearCookies()
{
    NativeMethods.InternetSetOption(IntPtr.Zero, NativeMethods.INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);
}

private static class NativeMethods
{
    internal const int INTERNET_OPTION_END_BROWSER_SESSION = 42;

    [DllImport("wininet.dll", SetLastError = true)]
    internal static extern bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer,
        int lpdwBufferLength);
}
+1

Source: https://habr.com/ru/post/1526253/


All Articles