我尝试实现自己的RoleProvider:
public class MyRoleManger : RoleProvider
{
public override bool IsUserInRole(string username, string roleName)
{
throw new NotImplementedException();
}
public override string[] GetRolesForUser(string username)
{
throw new NotImplementedException();
}
private string appName = "";
public override string ApplicationName
{
get { return appName; }
set { appName = value; }
}
....
}
这是我的Web.config:
<system.web>
.....
<roleManager defaultProvider="RoleManger" enabled="true" >
<providers>
<clear/>
<add name="RoleManger" type="UserManager.Client.Web.MyRoleManger" applicationName="MyApp"/>
</providers>
</roleManager>
<authentication mode="Windows"/>
<identity impersonate="true"/>
</system.web>
<system.webServer >
<security>
<authorization >
<clear/>
<add accessType="Allow" roles="anyRole"/>
<add accessType="Deny" users="?"/>
</authorization>
</security>
...
</system.webServer >
但IIS下的ASP.NET不会调用MyRoleManager方法。相反,它尝试从Windows安全组(AD)获得“anyRole”。如何强制IIS将MyRoleManager与Windows身份验证一起使用?