There are several problems with the script you posted.
Don't remove /Users/Shared - iTunes needs it and will fail on certain store and sharing operations.
dscl on Lion will still whine if you start it (it's looking for the missing plist) - even if you launch /System/Library/LaunchDaemons/com.apple.opendirectoryd.plist
as Ingmar Hupp has suggested.
I've never been one to worry about cleaning up the groups since I'm deleting user 501. The system will just add UID 501 back into the Admin and Staff groups the next time the Setup Assistant boots, so I do the following: (assume the short name of the user 501 is test)
- ⌘+S
/sbin/mount -uw /
cd /var/db/dslocal/nodes/Default/users/
rm test.plist
rm -rf /Users/test
rm /var/db/.AppleSetupDone
halt
I do use the official Users & Groups Preference Pane to delete all users except 501 and/or create the test user as 501 as needed since launchd can have jobs stuck if the users you are clearing aren't trivial users set up for simple updates as your case allows.
I would avoid saving a WiFi password or setting up WiFi outside the user account or use ethernet for your updates if you want to be fastidious about leaving as little of your settings behind (especially if the SSID/name isn't generic like Apple Network or has WEP/WPA keys).
FileVault 2 uses the GeneratedUID user attribute to save who is permitted to unlock an encrypted volume. If the GeneratedUID of a user differs from what was generated (or pulled from LDAP) when FileVault 2 was enabled, the user will not be permitted to unlock the machine, as their account will appear to be unavailable at the EFI menu. Also, this causes the crash of System Preferences on their Mac whenever they try to access the Security & Privacy prefpane.
This problem arises when /usr/bin/mcxrefresh
runs and pulls a null
value or a value different than what is stored locally from LDAP (if the attribute isn't defined for the user in question or is defined incorrectly, respectively), overwriting the GeneratedUID stored locally (which is generated and only stored locally when FileVault 2 is enabled without a matching LDAP attribute).
In other words, if an apple-generateduid value exists in LDAP for a user and is mapped properly on the users Mac to the GeneratedUID attribute, FileVault 2 will not generate a new value, but will instead use the value stored in LDAP.
I was able to resolve this issue by adding an attribute called apple-generateduid
to the LDAP entry of any user experiencing this issue. I could generate a random value for this attribute in Python by running the following one-liner from my terminal:
python -c 'import uuid; print str(uuid.uuid4()).upper();'
This isn't the only step, however. You must also add a mapping for this attribute on the client side. This is easily done using the following steps:
- Open System Preferences.
- Click Users & Groups.
- Click Login Options.
- Click on the Unlock Icon.
- Under Network Account Server, click Edit.
- Click to highlight your directory server.
- Under Services, double-click on your directory service (in my case, it was LDAPv3)
- In the window that slides open, highlight your configuration name, and then click the Edit... button.
- Under Search & Mappings scroll down and single-click on Users to highlight it.
- Click the Add button (the left one).
- Choose GeneratedUID from the list of available Attribute Types.
- In the right column, click the Add button, and type
apple-generateduid
. Click OK to save the changes until you're back at the main System Preferences dialog.
- At this point a mapping from GeneratedUID to
apple-generateduid
has been created. Now when OS X looks up the GeneratedUID value it will get the value of apple-generateduid from the user in questions LDAP entry.
Finally, it's important that the locally stored value of GeneratedUID and value stored on LDAP match. Run the following command and make sure the two GeneratedUID values match:
dscl /Search search /Users GeneratedUID $(dscl . read /Users/$(echo $USER) GeneratedUID | cut -d " " -f2)
Best Answer
Just fought this battle, you can drop the
dscl
line and use the following;Type the command :
Where
UserName
is their actual AD username.Berry