我有简单的会员提供者,有一个表"用户"使用UserId和Username.I希望将此表与窗口活动目录集成。
答案 0 :(得分:0)
首先将您的身份验证模式设置为Windows
<authentication mode="Windows" />
添加连接字符串
<connectionStrings>
...
<add name="AdConnectionString" connectionString=LDAP://*adserver*/DC=*domain* />
</connectionStrings>
然后添加会员资格
<membership defaultProvider="ADMembership">
<providers>
<add name="ADMembership"
type="System.Web.Security.ActiveDirectoryMembershipProvider,
System.Web,
Version=2.0.0.0,
Culture=neutral,
PublicToken=b03f5f7f11d50a3a"
connectionStringName="AdConnectionString"
connectionUsername="domain/user"
connectionPassword="pwd" />
</providers>
</membership>
您可以启用角色管理器
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
<providers>
<clear />
<add
name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider"
applicationName="/" />
</providers>
</roleManager>
最终内部控制器
[Authorize(Roles = "Domain\\Group1,")]
public ActionResult ActionName()
{
//...
}