【发布时间】:2018-06-26 16:05:27
【问题描述】:
我想在我的 Intranet 应用程序中使用 Windows Auth,但我需要扩展标识对象以获取一些额外的数据。截至目前,我只能访问身份用户中的域名。我尝试实现自己的用户/角色存储以拦截授权调用,然后使用域名访问我们的数据库并获取额外的数据。我实现了自己的商店,但似乎没有调用任何方法。当应用程序授权窗口用户时如何拦截,以便我可以转到我们的数据库并获取我需要放入用户对象的内容?
这是我的 Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAuthentication(IISDefaults.AuthenticationScheme);
services.AddIdentity<MyUser, IdentityRole>()
.AddUserStore<MyUserStore>()
.AddRoleStore<MyRoleStore>()
.AddDefaultTokenProviders();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseAuthentication();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc();
}
【问题讨论】:
标签: c# asp.net-core windows-authentication asp.net-core-identity