在ActiveDirectory认证库2.6.1-alpha中找不到ActiveDirectoryAuthenticat

本文关键字:1-alpha 找不到 ActiveDirectoryAuthenticat ActiveDirectory 认证 | 更新日期: 2023-09-27 18:02:07

当我试图在Active Directory Authentication Library 2.6.1-alpha中使用ActiveDirectoryAuthenticationException时,找不到它。

我可以用什么来检测失败的身份验证?

1.0.3代码:

try
{
    result = authContext.AcquireToken(todoListResourceId, clientId, redirectUri, PromptBehavior.Never);
    // A valid token is in the cache - get the To Do list.
    SignInButton.Content = "Clear Cache";
    GetTodoList();
}
catch (ActiveDirectoryAuthenticationException ex)
{
    if (ex.ErrorCode == "user_interaction_required")
    {
        // There are no tokens in the cache.  Proceed without calling the To Do list service.
    }
    else
    {
        // An unexpected error occurred.
        string message = ex.Message;
        if (ex.InnerException != null)
        {
            message += "Inner Exception : " + ex.InnerException.Message;
        }
        MessageBox.Show(message);
    }
    return;
}

2.6.1-alpha代码:

try
{
    result = await authContext.AcquireTokenAsync(todoListResourceId, clientId, redirectUri, PromptBehavior.Auto);
    // A valid token is in the cache - get the To Do list.
    return true;
}
catch (ActiveDirectoryAuthenticationException ex) // What to use here?
{
    if (ex.ErrorCode == "user_interaction_required")
    {
        // There are no tokens in the cache.  Proceed without calling the To Do list service.
    }
    else
    {
        // An unexpected error occurred.
        string message = ex.Message;
        if (ex.InnerException != null)
        {
            message += "Inner Exception : " + ex.InnerException.Message;
        }
        MessageBox.Show(message);
    }
}
return false;
}

在ActiveDirectory认证库2.6.1-alpha中找不到ActiveDirectoryAuthenticat

您是否在Windows Store应用程序中使用该库?该版本的库(即ADAL WinRT)没有将ActiveDirectoryAuthenticationException公开为公共类型,因为ADAL WinRT从不抛出异常。在AuthenticationResult中返回错误。

如果您在。net应用程序中使用ADAL 2.6.1-alpha,您可以找到异常类型