Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • LoremIpsum 1 post 71 karma points
    Oct 09, 2019 @ 14:06
    LoremIpsum
    0

    Automatically Disable Users after 30 Days of not being Logged In

    Hello. Is there a way to automatically disable all users that haven't logged in for more than 30 days? I have been looking through the Documentation, but I have only found how to do it manually.

    If not, do you have any pointers on how I might achieve this?

  • Shaishav Karnani from digitallymedia.com 354 posts 1638 karma points
    Oct 09, 2019 @ 15:01
    Shaishav Karnani from digitallymedia.com
    1

    Hi,

    You can call a scheduler service and executes below code that checks for Last Login Date greater than or equal to 30 days and Lock the User.

    IUserService us = Services.UserService;
    var userList = us.GetAll(1,100,out int totalRecords);
    foreach(var u in userList)
    {
        if ((DateTime.Now - u.LastLoginDate).TotalDays>=30) {
            u.IsLockedOut = true;
            us.Save(u);
        }
    }
    

    Cheers,

    Shaishav

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies