ASP.NET Windows Role Provider (AspNetWindowsTokenRoleProvider) not noticing a user being added to a new group



I am trying to create an application that uses rules to limit the groups that are authorized to access the application. I am using Windows authentication and the Windows Role provider for ASP.NET (AspNetWindowsTokenRoleProvider). I am using local groups to define the roles, as the domain that I am developing on, and the domain that the app will eventually be deployed to will be different.

When I initially setup deployed my application to an IIS7 server, and I setup the site to use basic authentication, with the proper default domain, everything worked fine for the users that were already assigned to the authorized groups. However, when I attempted to add a new user to any of the authorized groups, this user was never authorized to access the application. I have done everything save for rebooting the machine. I restarted IIS as well as deleted all temporary files and cookies on the client side, to no avail.

It should be stated that this is an ASP.Net MVC app, though I didn't think that would really make any difference. Here are the pertinent entries from my web.config:

<!-- use windows authentication -->
<authentication mode="Windows" />

<!-- use the Windows role provider -->    
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" />

<!-- global authorization rules -->
    <allow roles="admins,contractors"/>
    <deny users="*" />

For instance, let's say we have a user, "Domain\joe", that is not currently a member of the local "admins" group, but we want to add him. We go add him, and then when Joe attempts to login, he sees an error that he is not authroized (after several failed login attempts). No amount of IIS restarts or having Joe delete his cookies and other temporary files will solve this issue.

Is ASP.Net keeping some kind of secret role/group cache? How do you go about adding a new user to a group and then ensuring that the role provider will see that the user was added to a group?

1 ответов


Похоже, что существует задержка между моментом, когда пользователь добавляется или удаляется из группы, и временем, когда IIS улавливает это изменение. Существует параметр реестра, который вы можете установить, чтобы изменить время, в течение которого токены аутентификации пользователя кэшируются, или отключить кеширование все вместе. Однако изменение этого значения (UserTokenTTL), похоже, не повлияло на время, необходимое IIS для осознания того, что пользователь был добавлен в группу. На следующей странице содержится дополнительная информация о разделе реестра UserTokenTTL: