集成 ASP.NET MVC 2 和 Active Directory 以及 Windows 身份验证
我目前正在使用 Windows 身份验证和活动目录编写 MVC2 应用程序。我对 MVC2 还比较陌生,所以我对除了身份验证之外到底在哪里实现任何授权代码有点困惑。我知道您在 MVC2 应用程序中编辑 web.config 文件以启用 Windows 身份验证。这就是全部了吗?
在通过 Windows 身份验证对用户进行身份验证后检查用户角色,这是否会在控制器中实现?是否应该在 MVC 应用程序之外(例如在库或其他地方)实现?
任何对此的帮助将不胜感激。
I am currently writing an MVC2 application using both windows authentication and active directory. I am still relatively new to MVC2, so I am a little confused about exactly where to implement any authorization code In addition to Authentication. I know that you edit the web.config file in the MVC2 application to enable windows authentication for instance. Is that all there is too it?
In terms of checking for a users roles once that user is authenticated through Windows Authentication, would that be implemented in the controllers? Should that be implemented outside the MVC application like in a library or something?
Any help with this would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请注意不要混淆身份验证和授权。
身份验证是确定用户是谁。使用 Windows 身份验证非常简单:在 IIS 和 web.config 中启用它,仅此而已。当用户访问您的站点时,如果该站点位于域中,并且浏览器安全设置允许(默认情况下,如果站点位于 Intranet 区域,则在 Internet Explorer 上),他将自动进行身份验证。否则,他将被询问他的用户/密码。
授权是确定用户可以做什么。这是通过自定义逻辑启用的。
请参阅:
Be careful not to mix authentication and authorization.
Authentication is making sure who the user is. Using windows authentication is pretty simple : enable it in IIS and in web.config, that's all. When a user goes to your site, if it's on a domain, he will be automatically authenticated, if browser security settings allows it (by default on Internet Explorer if the site is intranet zone). Otherwise he will be asked his user/password.
Authorization is making sure what the user can do. This is enabled via custom logic.
See :