During user logon, add an entry to
HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Let it start a script on the computer
Check for the environment variable %LOGONSERVER%
Now you should know if the user is logged on to the domain or with cached credentials