Search code examples
c#asp.netdotnetnukednn9

DNN clear cache for a user after locking it out


There is a problem with DNN 9.1. After locking out a user (from code), the DNN cache doesn't refresh.

Scenario

  • User entered his/her password more than Membership.MaxInvalidPasswordAttempts; so, the user is locked out.
  • Logging by 'host' (superuser account), and searching for the locked user, the DNN doesn't display the user as locked. (actually, I was searching for the 'Unlock User' option)

Q

  • Is there any way to let the DNN know after locking a user from the code?
  • How much time, should I wait till the DNN cache refresh?

Solution

  • You can clear the cache programatically in DNN.

    DotNetNuke.Common.Utilities.DataCache.ClearModuleCache(TabId);
    DotNetNuke.Common.Utilities.DataCache.ClearTabsCache(PortalId);
    DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(PortalId, false);
    

    But I doubt this solves your issue since the lockout is not managed by DNN but by ASP.NET Membership. The lockout is real-time. If you go to Admin > User Accounts > Edit User Account you will see that "lockedout = true" on the Manage Account tab. At the bottom is a button to unlock a user.