如何使用Windows Active Directory身份验证和基于身份的声明?
发布时间:2020-12-13 21:16:46 所属栏目:Windows 来源:网络整理
导读:问题 我们希望使用Windows Active Directory将用户验证到应用程序中。但是,我们不想使用Active Directory组来管理控制器/视图的授权。 据我所知,没有一种简单的方式来结合AD和基于身份的声明。 目标 使用本地Active Directory验证用户 使用身份框架来管理
问题
我们希望使用Windows Active Directory将用户验证到应用程序中。但是,我们不想使用Active Directory组来管理控制器/视图的授权。 据我所知,没有一种简单的方式来结合AD和基于身份的声明。 目标 >使用本地Active Directory验证用户 尝试(失败) > Windows.Owin.Security.ActiveDirectory – Doh。这是对于Azure AD。没有LDAP支持。他们可以把它称为AzureActiveDirectory吗? 任何帮助将不胜感激。我已经很久很久就被困在这个问题上,并且会很感激外界的关注。
鞋子你的解决方案推动我朝着在MVC6-Beta3 Identityframework7-Beta3 EntityFramework7-Beta3上为我工作的方向:
// // POST: /Account/Login [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<IActionResult> Login(LoginViewModel model,string returnUrl = null) { if (!ModelState.IsValid) { return View(model); } // // Check for user existance in Identity Framework // ApplicationUser applicationUser = await _userManager.FindByNameAsync(model.eID); if (applicationUser == null) { ModelState.AddModelError("","Invalid username"); return View(model); } // // Authenticate user credentials against Active Directory // bool isAuthenticated = await Authentication.ValidateCredentialsAsync( _applicationSettings.Options.DomainController,_applicationSettings.Options.DomainControllerSslPort,model.eID,model.Password); if (isAuthenticated == false) { ModelState.AddModelError("","Invalid username or password."); return View(model); } // // Signing the user step 1. // IdentityResult identityResult = await _userManager.CreateAsync( applicationUser,cancellationToken: Context.RequestAborted); if(identityResult != IdentityResult.Success) { foreach (IdentityError error in identityResult.Errors) { ModelState.AddModelError("",error.Description); } return View(model); } // // Signing the user step 2. // await _signInManager.SignInAsync(applicationUser,isPersistent: false,authenticationMethod:null,cancellationToken: Context.RequestAborted); return RedirectToLocal(returnUrl); } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows 安装 jdk 7和8
- windows – Python 3:捕获图像
- .net – 为什么要使用Microsoft AntiXSS库?
- windows – 阻止手动睡眠的SetThreadExecutionState
- windows-7 – .NET Framework 4.0和Aero Glass问题的绘图
- windows-server-2003 – 服务器2008系统分区的建议大小是多
- windows-server-2003 – Windows文件服务器性能调优
- 如何在Windows上的git bash(msy??sgit)中完全运行grep?
- 设置服务器以承载所有LAN设备的Windows更新
- Windows Azure网站是32位还是64位?