Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Account Expiry

Hi there,


I work at a college as the Mac Support Speciallist. We have an OS X server that is integrated with our Active Directory setup. The Library Macs are tied to this server so students can log in with their active directory accounts. This was all set up by my predecessor so I am trying to make sense of everything here so bear with me... it looks like he had configured the server to have accounts be mobile, and expire after 24 hours (meaning the local home folder would be deleted after that time). However, my research indicates that this will not work when using active directory accounts. And as a matter of fact, everyone here was under the impression that it WAS auto deleting the accounts, although all of the Macs have like 400 accounts on them now, apparently over the course of a year since the server was set up.


So my question is this: Is there a way to have the accounts delete on their own? We want the luxury of the students being able to login with their network credentials, but it isn't super important for them to store information for a long duration of time on the library computers, so having them expire/delete is fine even though it is not being synced to a server somewhere. The only option I can think of is to write a startup script to delete the accounts and have the machine auto restart at like 3 AM so it runs everyday. Any other ideas would be much appreciated!

Posted on Jun 28, 2013 7:18 AM

Reply
Question marked as Best reply

Posted on Jun 28, 2013 7:30 AM

Lets be clear on nomencalure: You don't want to delete the account. You want to delete the account's homefolder on the server. Correct?


I don't believe there is anything in OS X Server that manages account folder deletion (there are login controls, but the data would still be there). You could easily write a script however to delete the home folders. What is your experience in shell or Applescript?


You don't need to restart the server to run a script, delete folders or even manage accounts. If you want to write a script that launches at regular intervals, you can do so using launchd.


https://developer.apple.com/library/mac/documentation/darwin/reference/manpages/ man8/launchd.8.html


Does that help?

14 replies
Question marked as Best reply

Jun 28, 2013 7:30 AM in response to MyrkridianRhapsody

Lets be clear on nomencalure: You don't want to delete the account. You want to delete the account's homefolder on the server. Correct?


I don't believe there is anything in OS X Server that manages account folder deletion (there are login controls, but the data would still be there). You could easily write a script however to delete the home folders. What is your experience in shell or Applescript?


You don't need to restart the server to run a script, delete folders or even manage accounts. If you want to write a script that launches at regular intervals, you can do so using launchd.


https://developer.apple.com/library/mac/documentation/darwin/reference/manpages/ man8/launchd.8.html


Does that help?

Jun 28, 2013 7:57 AM in response to JaimeMagiera

Thanks for the response Jaime. Yes I should be more clear: there are no open directory accounts on our OS X Server, and there are no home folders being stored/synced on the OS X server. All we are using OS X server for is to set preferences (dock, permissions, etc.) for a particular group of computers. When someone logs into a remote machine in the library, their credentials are verified in active directory, and a local home folder is made for them. To my knowledge there is no home folder anywhere other than the local machine. So when I say "delete the account", I mean delete it from the local machine. It will still exist in active directory of course, so the next time they log in, they will see a fresh account with all of the managed preferences I have set for them.


Make sense? There is a possibility I have this wrong mind you, but this is what I have deduced from the way things seem to be working.

Jun 28, 2013 8:38 AM in response to JaimeMagiera

Snow Leopard Server. I found this discussion link which seems to validate the thought that active directory doesnt play well with mobile homes/account expiry:


https://discussions.apple.com/thread/4738153?start=0&tstart=0


And I guess that answers my question... other than knowing what my options are for forcing these mobile accounts to delete on the remote machines.

Jul 8, 2013 10:21 AM in response to Peter Greco

So I got the script working. I found most of it on another site but modified it a little bit. Here it is:


#!/bin/bash


UserList=`/bin/ls /Users | /usr/bin/grep -v "Shared"`


for u in $UserList ; do


if [[ `/usr/bin/dscl . read /Groups/admin GroupMembership | /usr/bin/grep $u -c` == 1 ]]


then /bin/echo "Admin account detected skipping..."


else /usr/bin/dscl . delete /Users/$u && /bin/rm -rf /Users/$u


fi


rm -rf /Library/Managed\ Preferences/*


done


I then used Lingon X to write a launch daemon which will run the script every day at 5:30 AM. This way it will only delete user account information when no one is on the computer. You also have to make sure that your computer isn't asleep when the script is run, or else it will just skip it and wait until the next run cycle. So what you could do is set the launch daemon to run the script at 5:31 AM every Monday, but also set your Energy Saver prefs to wake up the machine at 5:30 AM every Monday. You could also build into the script to pass over any currently logged in users, but this is taking up too much of my time and seems to be working just fine.

Account Expiry

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.