Reputation: 346
I want to redirect to a login page without the htaccess prompt showing up if a valid-user is not found
i have a working htaccess auth
AuthName "My name"
NTLMBasicRealm "DOM"
NTLMAuth on
NegotiateAuth off
NTLMAuthHelper "/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp"
NegotiateAuthHelper "/usr/bin/ntlm_auth --helper-protocol=gss-spnego"
NTLMBasicAuthoritative on
AuthType NTLM
AuthType Negotiate
Require valid-user
ErrorDocument 401 /index.php
Which sets the Windows name as $_SERVER['REMOTE_USER'] as long as a valid-user is found. if not the htaccess prompt pops up and you need to manually cancel it to get redirected
if i remove Require valid-user, $_SERVER['REMOTE_USER'] is null.
Is there a way to Authenticate an User but if not automatically found redirect without prompt?
Upvotes: 0
Views: 1286
Reputation: 40938
The first step in Windows Authentication is returning an HTTP 401 response to the browser. If the site is trusted, the browser will automatically send the current user's credentials. If not, the browser prompts for credentials. There is no way to change that behavior.
But you could refactor your site a bit. I described in another answer how to attempt Windows Authentication in the background and fall back to forms authentication. That answer is specific to ASP.NET, but the same thing can be done with PHP and Apache too (although I can't tell you exactly how to do it).
The basic idea is:
Upvotes: 1