Mobile accounts and saving User Homes

Mobile accounts and saving User Homes

Our clients are generally still tied to a directory service for permissions management across their Xsan volumes. They also take advantage of this to remote into beefy systems in the server room to do their editing on fibre connected Macs. On these Macs we make sure the users have a mobile account so that the permissions work as expected.

These accounts are created with sudo /System/Library/CoreServices/ManagedClient.app/Contents/Resources/createmobileaccount -n $username. Then the home folder is created with sudo /usr/sbin/createhomedir -c -u $username so they don’t have to wait as long on first log in.

This works great when a new user is onboarded, but recently we have been working with contractors that come and go. The client’s IT department frequently removes the contractor’s account from directory services and then creates a new one when they come back. These new accounts generally have a different account name and UID. So we have needed to migrate the old home folder to their new account.

We do this by deleting the old account, but saving the home folder with System Settings or sudo /usr/sbin/sysadminctl -deleteUser $username -keepHome. Either of these result in the home folder being renamed “$olduser (Deleted)”. Now we create the new account as shown above. Then we change the owner on the old home sudo chown -R $newusername /Users/$olduser\ \(Deleted\)and move it into the place the system will look for the new users home folder. sudo mv $olduser\ \(Deleted\) /Users/$newusername. Now the user can log in with their new credentials, but still have any files and settings they had previously been working with.

Latest News

RSK Group