Monday, October 25, 2010

Change default keyboard layout for loginwindow

We discovered that a system restore image we used to deploy new Macs with had the wrong keyboard layout at the loginwindow. If you change the keyboard layout in the Accounts PrefPane, it just affects the currently logged in user.
Apples solution to this is either to reinstall Mac OS X or select to show the input menu in the loginwindow, this is two solutions that I can't accept, so I started digging and found a solution!

The settings are stored in /Library/Preferences/com.apple.HIToolbox.plist and changing these solved my problem.

Here is quick and dirty script to change the default keyboard layout to Swedish:


#!/bin/bash

# This will set default keyboard language to Swedish.

# Path to plist file
PLISTDOMAIN="/Library/Preferences/com.apple.HIToolbox.plist"

# Path to PlistBuddy
PB="/usr/libexec/PlistBuddy"

"$PB" -c "set :AppleDefaultAsciiInputSource:KeyboardLayout\ ID 7" "$PLISTDOMAIN"
"$PB" -c "set :AppleDefaultAsciiInputSource:KeyboardLayout\ Name Swedish\ -\ Pro" "$PLISTDOMAIN"
"$PB" -c "set :AppleCurrentKeyboardLayoutInputSourceID com.apple.keylayout.Swedish-Pro" "$PLISTDOMAIN"
"$PB" -c "set :AppleEnabledInputSources:0:KeyboardLayout\ ID 7" "$PLISTDOMAIN"
"$PB" -c "set :AppleEnabledInputSources:0:KeyboardLayout\ Name Swedish\ -\ Pro" "$PLISTDOMAIN"

exit 0

Tuesday, October 19, 2010

Create mobile account for two different users with the same name fails

We discovered this today, and we haven't found any information about it anywhere, so...

If you have a mac bound to an Active Directory where there are users with the same name but different usernames, you may see that certain users cannot login to the mac. This happens when you have "Create mobile account at login" activated and a user tries to login who has the same name as a previously logged in user.

What is going wrong then? I don't know exactly, besides that it's the "RecordName" key that is the problem. There cannot be two users in the local database that has a value in RecordName matching any other user's value in RecordName.

If you change the value to something else on the first user, the second user can login.

Delete the value:
sudo dscl . delete /Users/uname1 RecordName "John Doe"

Append a new value:
sudo dscl . append /Users/uname1 RecordName "John Marc Doe"

Or simply change:
sudo dscl . change /Users/uname1 RecordName "John Doe" "John Marc Doe"

UPDATE 2010-10-20
I made a bugreport to Apple regarding this yesterday and got a response that they need logs. I will upload the logs today to Apple and then we'll see what they have to say about it...

UPDATE 2010-10-25
Apple says this is expected behavior. I have replied that I disagree.