I recently came to a case where I needed to create users that are activated and/or deactivated at a specific date. I then found an angle for this in an older Security Cook Book of Sitecore in the section "How to Extend the Default User Profile" and I found that there would be a good sitecore-like approach.

Required Sitecore core-database configurations

The first thing is to go to the Core database in the Sitecore backend, find the default user profile item located here /sitecore/system/Settings/Security/Profiles/User, duplicate it and give it a name. I named mine Timecontrolled User. After this add the needed datetime-fields to the new template.

UserTemplate

Still in the Core database context go to /sitecore/system/Settings/Security/Profiles and add your new profile.

This is it for now in Sitecore.

Enhance your project with a new class

Switch to Visual Studio and create a new class in your project. Name it e.g. UserControlTask.

The first thing we want is to get all the users and iterate through them. If a user meets the requirement to enable or disable we set the IsApproved property to true/false and save.

Setup a custom task command in Sitecore

Now that we have our code we switch back to the Sitecore backend and go /sitecore/system/Tasks and add a new command in the Commands folder.

Fill in the fields as you are used to and the select the new profile. In the type field insert the path to your class and the assembly and write our method name Execute in the method field.

command

The select the Schedules folder and insert a new schedule. In the commands field choose the command we just created. You can leave the items field empty and in the schedule field enter the pattern when the task should run. If you need help with defining your schedule there is a good explanation here.

schedule

Time to test it out

Now that we have everything in place go to the User Manager and create a new user.

CreateUser

After saving open the user in the editor and select the profile tab and edit the profile.

Fill in the dates needed in the newly created fields.

EditProfile

That is the whole magic.