Apache2, PHP: create automatic ntlm login page
===

I have Apache2 with PyAuthenNTLM2 module (see https://github.com/Legrandin/PyAuthenNTLM2). This Apache module put the windows user name in $_SERVER['REMOTE_USER'].

To enable this you need to put a directive similar to following in apache config (or htaccess) for a file or directory:

    Order allow,deny
    Allow from all
     
	AuthType NTLM
	AuthName "Test"
	require valid-user

	PythonAuthenHandler pyntlm
	PythonOption Domain TESTDOMAIN
	PythonOption PDC 192.168.0.10

The thing is that any files under such a directory (including css, js) are only accessible if the NTLM credential are supplied by browser. So using a include that is "ntlm protected" in a page that is not will not work. 

Anyway what I want is a single page that sets up a session and further authorization is done using the session. if session is not set yet or expired the user is invisibly transferred to the automatic login page and then back to the actual requested page.

how can I achieve that?