c# - 无法验证 Windows Live 帐户 Windows Azure AD

标签 c# azure azure-active-directory

用户是在 azure AD 中为我构建的 native 应用程序创建的。我希望用户使用他们的 windows live ID(如果有的话),否则我会为他们创建一个 AD 帐户。

AD 帐户 能够登录,但每当 Windows Live 帐户尝试登录时,我都会收到以下错误消息

No service namespace named 'timetray' was found in the data store.

我不确定这意味着什么,服务命名空间是什么,或者在哪里可以找到数据存储。

我正在使用的服务命名空间的名称是我在 Active Directory 中配置的应用程序的资源 ID URI

 private Uri redirectUri = new Uri("http://TimeTray");
    private string clientId = "{{Client-ID}}";
    private AuthenticationContext _authenticationContext;
    private string domainName = "common";
    private string resourceAppIdUri = "http://TimeTray";
    private string resourceBaseAddress = "http://timetray.azurohosted.com/";

    public void Authenticate(OnLoginComplete onLoginComplete)
    {
        CredManCache creds = new CredManCache();
        _authenticationContext = new AuthenticationContext("https://login.windows.net/" + domainName, creds);
        AuthenticationResult authenticationResult = _authenticationContext.AcquireToken(resourceAppIdUri, clientId, redirectUri);
       // _authenticationContext.AcquireToken(
        UserEntity user = new UserEntity();
        user.NTUserName = authenticationResult.UserInfo.UserId;
        user.SID = authenticationResult.UserInfo.UserId;
        onLoginComplete(user);
    }

最佳答案

我假设您正在使用 AAD 设置 ADAL。

创建 AuthenticationContext 时:

而不是 https://login.windows.net/ "+ 域名(常用)

尝试

https://login.windows.net/[Azure AD 中客户端上配置的 Web API 的指南]/FederationMetadata/2007-06/FederationMetadata.xml

在其数据存储中,Azure 现在将查找服务命名空间 [guid],而不是从登录名“billy”@timetray.onmicrosoft.com 延迟的内容。

参见 MSDN 示例 http://code.msdn.microsoft.com/AAL-Native-Application-to-fd648dcf#content

它指出“将权限设置为 https://login.windows.net/common 以推迟选择 AAD 域,直到用户登录。”

此外,请使用 http://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory/

我想您还需要在 Azure AD 中创建链接到现有 Microsoft 帐户的用户。

关于c# - 无法验证 Windows Live 帐户 Windows Azure AD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18849622/

相关文章:

azure - 地形计数索引和长度

azure - 在 Azure 中取消 fork 存储库与父级存储库的关联

azure - 使用 Xamarin Forms 通过自签名证书向 Azure AD 进行身份验证

azure - 如何验证 Azure Active Directory 中刷新的 id_token 的签名

powershell - 禁止标准用户在 Azure Active Directory 中浏览用户

c# - 什么时候可以说发生了方法组转换?

c# - Azure Functions 计划计时器

azure - CosmosClient 能否给出由于限制而发生的重试次数(http 429)?

javascript - "The JSON request was too large to be deserialized"MVC KnockoutJs

c# 如何使用 DirectShow 播放加密视频?