Why do shared Excel workbooks open as Read-Only on OS X sometimes?

Most often seen in office and company environments that use Macs, on occasion a certain user will be unable to edit a shared Office document. Because it's shared, the document keeps track of the UID of each user curently accessing it. If two users possessing the same UID try to edit it at the same time, the second one will get locked out because Office thinks they already have it open.

Since the default UID on Macs is 501 and progresses by 1 for each additional user, this ends up being quite a mess the more Macs that need to access it.

Microsoft's official solution is to use networked user accounts, but this is not always possible depending on what kind of work environment you are in. An easier fix is to change the problem user's UID. Luckily, this is fairly simple using OS X's built-in `dscl` command, although also very simple to make a mistake with.

You can see a list of the currently used UIDs by typing
dscl . -list /Users UniqueID | awk '$2 > 400'

Which will return:

administrator 501
apple 502
drsavoye 503


By using this on all machines, you can immediately see which users match UIDs, even if the usernames don't match.

To change a UID, use dscl . -delete /Users/drsavoye UniqueID and dscl . -create /Users/drsavoye UniqueID 604

Generally you will want to use a higher number to ensure that it does not fall within the range of the Mac's default UIDs. Now you must change the UID on the user's home directory as well. If you miss this step, the user will not be able to access or create any files.

By using ls -l /Users, you will see that the directory "drsavoye" is now shown as drwxr-xr-x 15 503 staff or similar, because the recorded owner (drsavoye) doesn't match the new UID (604). To update it, you can either use
chmod -R drsavoye:staff /Users/drsavoye, or
chmod -R 604:staff /Users/drsavoye

That's it! You should now be able to access all your Office documents. You may have to use `sudo` in order to use dscl if you are not authenticated as root.

No comments:

Post a Comment