Assuming all your Domain Controllers are Windows Server 2003 or later you can do this with native Active Directory's dynamic objects functionality without any scripting.
Let's say that a user account, "Bob", needs to be in the "Accounting" group for 24 hours.
Create a "Bob in Accounting 24 Hours" group and specify an entry-TTL
for 24 hours (the duration you want the group to remain in the Active Directory) at the time of creation.
Add the "Bob in Accounting 24 Hours" as a member of the "Accounting" group
Add the "Bob" user account as a member of the "Bob in Accounting 24 Hours" group
Upon the "Bob" user account's next logon it will be a member of the "Accounting" group through the nested group membership of the "Bob in Accounting 24 Hours" group into the "Accounting" group. At the end of 24 hours all the domain controllers will garbage-collect the "Bob in Accounting 24 Hours" group and "Bob" will no longer be a member of "Accounting".
The trick is that non-dynamic objects cannot be converted to dynamic after their creation. Using group nesting, though, gets you around that limitation in this instance.
You'll need to use a tool other than "Active Directory Users and Computers" to create the group because you'll need to set the entry-TTL
at the time of the group's creation. The script in this blog entry might be a starting place (it's built to create User objects) or, alternatively, you could just use ldifde
or csvde
to do the creation, too.