相关疑难解决方法(0)

在Azure Active Directory B2C中按组授权

我试图弄清楚如何授权使用Azure Active Directory B2C中的组.我可以通过用户授权,例如:

[Authorize(Users="Bill")]
Run Code Online (Sandbox Code Playgroud)

然而,这不是很有效,我看到很少用例.另一种解决方案是通过角色授权.但是由于某些原因,似乎并没有wowrk.例如,如果我为用户提供"全局管理员"角色,请尝试:

[Authorize(Roles="Global Admin")]
Run Code Online (Sandbox Code Playgroud)

这是行不通的.有没有办法通过群组或角色进行授权?

asp.net-mvc azure azure-ad-b2c

25
推荐指数
3
解决办法
1万
查看次数

Azure AD B2C - 角色管理

我有一个与Azure AD B2C连接的Asp.NET MVC应用程序.

在管理员设置中,我创建了一个管理员组:

在此输入图像描述

在我的代码中我想使用 [Authorize(Roles = "Administrator")]

使用常规的Azure Active Directory,它很容易添加(只需3行代码).但对于Azure AD B2C,我找不到任何有用的教程或示例.也许你可以告诉我我需要修改什么.

这是我的Startup.Auth.cs的ConfigureAuth方法

public void ConfigureAuth(IAppBuilder app)
{
    app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

    app.UseCookieAuthentication(new CookieAuthenticationOptions());

    app.UseOpenIdConnectAuthentication(
        new OpenIdConnectAuthenticationOptions
        {
            // Generate the metadata address using the tenant and policy information
            MetadataAddress = String.Format(AadInstance, Tenant, DefaultPolicy),

            // These are standard OpenID Connect parameters, with values pulled from web.config
            ClientId = ClientId,
            RedirectUri = RedirectUri,
            PostLogoutRedirectUri = RedirectUri,

            // Specify the callbacks for each type of notifications
            Notifications = new OpenIdConnectAuthenticationNotifications
            {
                RedirectToIdentityProvider = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc azure asp.net-mvc-5 azure-ad-b2c

16
推荐指数
1
解决办法
6131
查看次数

标签 统计

asp.net-mvc ×2

azure ×2

azure-ad-b2c ×2

asp.net-mvc-5 ×1

c# ×1