简体   繁体   English

ASP.NET User.IsInRole 说明

[英]ASP.NET User.IsInRole clarification

I need to implement authorisation based on Active Directory group.我需要实现基于 Active Directory 组的授权。 Could someone please clarify how the code below works?有人可以澄清下面的代码是如何工作的吗?

User.IsInRole("Human Resouces")

Question:问题:

  1. Is role "Human Resources" checked against Active directory group?是否针对 Active Directory 组检查角色“人力资源”?
  2. If not, how do I enable so that isInRole actually checks the Member Group in Active directory.如果没有,我该如何启用以便 isInRole 实际检查 Active Directory 中的成员组。
  3. Or does it check against role on IIS Server machine?或者它是否检查 IIS 服务器机器上的角色?

Thank you.谢谢你。

This requires some setup, check out these following resources:这需要一些设置,请查看以下资源:

http://msdn.microsoft.com/en-us/library/ms180890(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/ff650308.aspx http://msdn.microsoft.com/en-us/library/ms180890(v=vs.80).aspx http://msdn.microsoft.com/en-us/library/ff650308.aspx

If you follow the approach of defining a principal that sets the principal to the User property, you can use User.IsInRole to check the AD authorization store.如果您遵循定义将主体设置为 User 属性的主体的方法,则可以使用 User.IsInRole 来检查 AD 授权存储。 The User (an IPrincipal) represents the information from the authentication mode setting (either forms or windows);用户(IPrincipal)表示来自身份验证模式设置的信息(forms 或 windows); AD is typically setup through forms authentication. AD 通常通过 forms 身份验证设置。

HTH. HTH。

I think you should look at this MSDN post it explain the things as your requirements are.我认为您应该查看此 MSDN 帖子,它根据您的要求解释了这些内容。
How To: Use Windows Authentication in ASP.NET 2.0如何:在 ASP.NET 2.0 中使用 Windows 身份验证

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM