So, yesterday we found what must be one of the scariest "bugs" I've yet to come across in OSX.
A user failed to get a proper home folder when logging on to a AD-connected OSX Server and closer examination revealed that his home folder and all contents where owned by another account.
Turns out, Apple translates the 128-bit "GeneratedUID" from AD to a 32-bit "UniqueID" which is used in (at least) the filesystem.
And, it's even worse, they don't translate the entire 128bit UID, but directly uses the first 32 bits. Like this:
My user in our AD:
GeneratedUID: 0D7EB1D5-657B-4D24-B8E4-FB08AF84CEB2
UniqueID (on a mac): 226406869
Proof:
echo "obase=16; 226406869" |bc
D7EB1D5
Which means that there might be more than one user in the AD that has the same UID on a mac! In our AD, 6 users are affected, they share UID on a mac. So far, only one user has encountered problems, but this might change at anytime... Our AD contains 108000 user accounts and grows steadily (university)
And worse: the same principle is seemingly used for all objects the mac looks up in the AD.
Mac OS X only uses the first 32 bits of any obejct and searches the AD and presents the first reply. So, if suddenly a new group in the AD gets the same first 32 bits as the group "Domain Users", files might be owned by any of those 2 groups and there's no way of telling which one the Mac will use, or it might change the next time it contacts the AD. This might of course lead to an amazing array of strange behaviours...
Not confirmed but likely: computers connected to AD might not be able to update it's computer password since OSX might not be able to present itself as the correct computer.
Scariest part: I have yet to figure out a way to fix this. If Apple changes the way UID is calculated from AD, that means that every mac user connected to the AD will get a different UID and GID, and all versions of Mac OS X prior to the fixed version will be in trouble... (and there'll be a lot of work changing ownership on all files on all clients...)
The only way to fix this for now is to use the ability in the AD-plugin to use another attribute as UID for users and GID in groups. That, on the other hand means that we have to construct new UID/GID and populate our AD, and change ownership on every mac connected anyways... not fun.
I've just posted a bugreport and by connections it's on it's way upwards within Apple. For now we are scanning our AD for potential conflicts and will be holding a meeting with the AD-people and management to try to get a plan on the road in case something breaks bad.

