简体   繁体   English

具有Active Directory身份验证的MVC 5应用失败授权属性

[英]MVC 5 app with Active Directory authentication failing Authorize attribute

I have an MVC 5 web app that is set up to use Forms authentication as per this this link 我有一个MVC 5 Web应用程序,该应用程序被设置为根据此链接使用表单身份验证

It is successfully validating against LDAP (ie, the call to Membership.ValidateUser(model.UserName, model.RememberMe) returns true) but when it redirects to the Index action of my HomeController, it is hitting the [Authorize] attribute and thinking that the user is not authorized for some reason, so it redirects to the login page again. 它已成功针对LDAP进行了验证(即,对Membership.ValidateUser(model.UserName, model.RememberMe)的调用返回true),但是当它重定向到HomeController的Index操作时,它击中了[Authorize]属性并认为用户由于某种原因未获得授权,因此它将再次重定向到登录页面。

What am I missing here? 我在这里想念什么?

You need to add the authentication cookie to the response something like this: 您需要将身份验证cookie添加到响应中,如下所示:

   FormsAuthentication.SetAuthCookie((model.UserName, model.RememberMe)

or you can do it manually like it's described in this link 或者您也可以按照此链接中所述手动进行操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MVC4表单身份验证Active Directory自定义授权属性 - MVC4 Forms Authentication Active Directory Custom Authorize Attribute MVC 4重定向失败,带有授权属性AllowAnonymous - MVC 4 Redirect failing with Authorize Attribute, AllowAnonymous 在Azure Active Directory中使用Authorize属性 - Using the Authorize attribute with Azure Active Directory ASP.NET MVC 5:应用程序池,Windows身份验证和Active Directory - ASP.NET MVC 5: App Pool, Windows Authentication and Active Directory 无法在授权属性上动态发送 Active Directory 组名称 - Unable to dynamically send the Active Directory group name on authorize attribute 从Active Directory进行身份验证,但在MVC中从SQL数据库授权角色 - Authenticate from Active Directory but Authorize Roles from SQL Database in MVC IIS Express中使用Active Directory进行MVC身份验证/授权 - MVC Authentication/Authorization with Active Directory in IIS Express 使用Active Directory或成员资格数据库进行MVC 4身份验证 - MVC 4 authentication with Active Directory or Membership database 使用活动目录的MVC 5身份验证,没有单一登录 - MVC 5 authentication using active directory with no single sign on ASP.NET MVC上的Active Directory身份验证 - Active Directory Authentication on ASP.NET MVC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM