Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8335397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:40:01+00:00 2026-06-09T03:40:01+00:00

I have Apache2 with PyAuthenNTLM2 module (see https://github.com/Legrandin/PyAuthenNTLM2 ). This Apache module put the

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T03:40:02+00:00Added an answer on June 9, 2026 at 3:40 am

    I came up with following script / solution:

    <?php
    
    $validApplications = array("Application_1", "Application_2");
    $baseUrl = 'http://' . $_SERVER["SERVER_NAME"] . '/';
    
    if(!isset($_SERVER["REMOTE_USER"])){
        header('HTTP/1.1 401 Not Authorized', true, 401);
        //...display error page
        exit(0);
    }
    
    if(!isset($_GET["applicationName"]) 
            || !in_array($_GET["applicationName"], $validApplications) ){
        header('HTTP/1.1 400 Bad Request', true, 400);  
        //...display error page
        exit(0);
    }
    
    $application = $_GET["applicationName"];
    
    if(!isset($_GET["returnTo"])){
        $returnTo = $baseUrl . $application . "index.php";
    } else {
        $returnTo = $_GET["returnTo"];
    }
    
    $sessionName = "PHP" . $application . "Session";
    
    session_name($sessionName);
    session_start();
    
    session_regenerate_id(TRUE);
    /* erase data carried over from previous session */
    $_SESSION=array();
    $_SESSION['login'] = $_SERVER['REMOTE_USER'];
    header("Location: " . $returnTo);
    ?>
    

    This script, lets call it login.php must be under an according Apache2 module that can set $_SERVER[“REMOTE_USER”] (I use PyAuthenNTLM2) like displayed in my Question.

    Each web page in ana application then must first check if $_SESSION[‘login’] is set or not and if not redirect to this login page:

    if (!isset($_SESSION['login'])) {
        $queryString = "returnTo=" . urlencode($_SERVER["REQUEST_URI"]) . "&applicationName=Application_1";
        header ("location: " . $baseUrl . "login.php?" . $queryString);
        exit(0);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This didn't work: Setting the umask of the Apache user Arch doesn't have a
I have a windows XP machine, installed apache at C:\Program Files\Apache Software Foundation\Apache2.2 I
I have followed all the instructions here: http://www.tonyspencer.com/2003/10/22/curl-with-php-and-apache-on-windows/ to install & config apache get
I have a PostgreSQL, php5, running on Apache2.0 (on a Windows machine.) I want
Is it possible for the apache2 user, http, to have environment variables like normal
I have a Windows/Apache2/PHP app that receives file using chunked encoding. The reason is
I have written an Apache2 module in C, now I am at the point
I have a Windows server 2008 with apache2. The server has 2 discs and
I have an apache2 server running Phusion Passenger. On this machine I have two
OS is specifically RHEL6 running Apache2. So in my Apache configuration, I have: LoadModule

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.