We use the ldap server authentication plugin to create moodle accounts when users login from Active Directory. Is there a recommended maintenance routine to remove old accounts from the moodle database. For example users that have not logged on for two years or users that no longer have an Active directory account.
Are you talking similar to longtimenosee feature.
In site admin >> plugins >> enrollment >> self enrollment
You can set to unenrol users after they are inactive for a specific period of time. http://docs.moodle.org/22/en/Self_enrolment#Unenrolling_students_who_haven.27t_been_active_on_the_course
or perhaps the cleanup settings http://docs.moodle.org/24/en/Cleanup