I just created this plugin, it's based on the original autologon code, but with a couple of additions, basically when a condition is matched (in the default case active!='Y'), you are redirected to the original site with the parameters user and active passed as GET requests.
So for example the user test/1234 in the webmail (webmail.example.com) that is not yet valid (state P), would be returned to
http://example.com/?user=test&active=P so we can deal with it on an external login page.
The code can be found here, feel free to comment, patch, etc.->
https://bitbucket.org/aseques/autologon_fail_redirect