I have had very similar issue to all described, but my users get logged out (or fast user switched, cannot tell) IMMEDIATELY as they login (well within 30 seconds AT MOST). They see the desktop, sometines they can click on the first app (Safari, whatever) and the screen then 'rotates' back to the login panel.
These are Brand New (to us) MacBook 5,2, Fresh Install of Mountain Lion, Directly Upgraded to 10.8.2. and NOTHING ELSE installed (yet), and one machine keeps doing this. Two other laptops seem to not exhibit this issue (maybe not yet??).
To me, I knew it has to be some corrupted plist or some b0rked file SOMEWHERE but how to find it?
On a lark, I installed AppleJack and let it auto process. It found a corrupt plist, /Library/Preferences/com.apple.preferences.sharing.plist
It is zero k, and owned by my account. I only have used that account to ssh into that laptop, so why would a preferences file be created for a low level process like this?
Well, AppleJack moves any 'corrupted' pfile to a new /Library/Preferences\ \(Corrupt\) folder, I rebooted and viola! user can login, no forced switch/logout!
Here is some background/detail information
Before AppleJack, trying to troubleshoot this from terminal:
(~)- ssh -C -2 YYY@XXX
Password:
Last login: Tue Dec 25 20:51:05 2012 from MAIN_SERVER
Could not chdir to home directory /Network/Servers/MAIN_SERVER/Volumes/Users/Users/ME: Invalid argument
-bash: /Network/Servers/MAIN_SERVER/Volumes/Users/Users/ME/.bash_profile: Invalid argument
XXX:/ YYY$
After AppleJack found the corrupt file:
(~)- ssh -C -2 YYY@XXX
Password:
Last login: Wed Dec 26 08:03:43 2012 from MAIN_SERVER
start .bash_profile '-bash'
Calling OUT to .bash_login from .bash_profile '-bash'
start .bash_login
... (Snip for brevity, but YAY!!!)
XXX:/ YYY$
Here is the 'corrupt file info
(/Library/Preferences (Corrupt))- ll
total 0
drwxrwxrwx 3 root wheel 102 Dec 26 09:01:06 2012 ./
drwxr-xr-x+ 62 root wheel 2108 Dec 26 09:01:06 2012 ../
-rw-r--r-- 1 ME staff 0 Nov 23 17:52:17 2012 com.apple.preferences.sharing.plist