A simple authentication handler either accepts or rejects users. If you instead want to give them different output if authentication fails, you could use a pair of Perl handlers, one on the authentication hook and one on content generation. If the user tries to authenticate, the authentication handler checks that the username and password match (in this case, in the Unix password file), and creates a "note" that the content handler should enter authenticated mode. (We use the pnotes method here rather than notes since there is no need for the note to be sent back to the web server; if we needed to log the contents of the note, then the pnotes method would not be sufficient.) Otherwise, the authentication handler does not create a note and simply allows the user through in anonymous mode.
The content handler then checks whether the note is present, and prints one page or the other depending on the result of that check.
To install this example using the Administration Server user interface, put the above code in
You will also need to enable the htaccess support, and create an htaccess file with an 'authname' entry, and a global htaccess file with 'passenvauthorization on' in a suitable 'Directory' tag.
Content Manager [Administrator] 16 December 2005
Comments are closed for this post.