ASPNET Core中的广告组无法正常工作

时间:2018-07-10 05:31:36

标签: asp.net-core asp.net-core-mvc active-directory-group

我在Startup.cs中使用以下设置

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();

    services.AddAuthorization(options =>
    {
        options.AddPolicy("RequireCommericalRole", policy => policy.RequireRole("SG_Commercial"));
    });

    var appSettings = Configuration.GetSection("AppSettings");
    services.Configure<AppSettings>(appSettings);
}

并在控制器中

[Authorize(Policy = "RequireCommericalRole")]
[Produces("application/json")]
public class AppSettingsController : Controller
{

    private readonly AppSettings _appSettings;

    public AppSettingsController(IOptions<AppSettings> appSettings)
    {
        _appSettings = appSettings.Value;
    }

    [HttpGet]
    public IActionResult GetSettings()
    {
        var apiURL = _appSettings.API_URL;
        return Ok(apiURL);
    }
}

不适用于我的广告组设置。 Windows用户在正确的组中。

请告知

0 个答案:

没有答案