2014-02-10 2 views
4

WAAL 토큰을 얻기 위해 ADAL 라이브러리를 사용하여 로그인 흐름을보다 잘 제어 할 수있는 방법을 알고 싶습니다.ADAL AuthenticationContext에서 로그인 흐름을 제어하는 ​​방법은 무엇입니까?

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")); 

사용자에게 로그인하라는 메시지가 표시됩니다. 내게는 라이브 ID를 통해, 내 고객의 컴퓨터는 조직 계정을 통해 이루어지기 때문에 전환 할 방법이 없습니다. 컴퓨터가 실행중인 현재 세션이 하늘/파랑으로 이미 기록 된 방법/현재 세션에 의해 제어되는 것으로 보입니다.

이것을 제어하기 위해 AcquireToken 호출에서 무엇을 할 수 있습니까? 사람들이 Azure에 로그인 할 때 정상적인 흐름을 트리거 할 수 있다면 라이브 ID 나 조직 로그인의 경우 선택할 수있는 것이 가장 좋습니다.

나는 이것을 시도 : 행운과

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"); 

.

답변

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); 
} 
+0

이것은 ADAL 방법에 포함되어야합니다. 네이티브 클라이언트는 때때로 다시 시작하지 않고 로그인 한 사용자를 변경해야합니다! –

관련 문제