Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
624 views
in Plugins by

Hi all, 

 

I have created a small plugin module (based on this ldap_plugin) for auto login via NTLM results for my intranet. It logs users in under the supplied credentials but when the user clicks logout I get a 400 Bad Request error.

 

Can anyone shed some light? 

 

I have included my plugin code below:

 

ntlm_login.php{

 

<?php
 
class ntlm_login {
 
  function load_module($directory, $urltoroot)
  {
    $this->directory=$directory;
    $this->urltoroot=$urltoroot;
  } // end function load_module
 
  // check_login checks to see if user is already logged in by looking for
  // a cookie or session variable (dependent on 'remember me' setting
  function check_login()
  {
    if(!isset($_COOKIE["qa-login_fname"]) && !isset($_SESSION["qa-login_fname"])) {
      require_once QA_INCLUDE_DIR."../qa-plugin/qa-ldap-login/qa-ntlm-func.php";
      if($user_data = get_user_data())
      {
        $fname = $user_data[0];
        $lname = $user_data[1];
        $email = $user_data[2];
        $username = $user_data[3];
          
      if(isset($inremember)) {
          if($inremember == 'true') {
          setcookie("qa-login_lname", $lname, time() + $expire, '/');
          setcookie("qa-login_fname", $fname, time() + $expire, '/');
          setcookie("qa-login_email", $email, time() + $expire, '/');
          setcookie("qa-login_user", $user, time() + $expire, '/');
        } else {
          $_SESSION["qa-login_lname"] = $lname;
          $_SESSION["qa-login_fname"] = $fname;
          $_SESSION["qa-login_email"] = $email;
          $_SESSION["qa-login_user"] = $user;
        }
      }
      } else {
      
      }
    } else {
      if(isset($_COOKIE["bdops-login_fname"])){
        $fname = $_COOKIE["qa-login_fname"];
        $lname = $_COOKIE["qa-login_lname"];
        $email = $_COOKIE["qa-login_email"];
        $username = $_COOKIE["qa-login_user"];
      } else {
        $fname = $_SESSION["qa-login_fname"];
        $lname = $_SESSION["qa-login_lname"];
        $email = $_SESSION["qa-login_email"];
        $username = $_SESSION["qa-login_user"];
      }
      $source = 'ldap';
      $identifier = $email;
 
      $fields['email'] = $email;
      $fields['confirmed'] = true;
      $fields['handle'] = $username;
      $fields['name'] = $fname . " " . $lname;
      qa_log_in_external_user($source,$identifier,$fields);
    }
  } // end function check_login
 
  function match_source($source)
  {
    return $source=='ldap';
  } // end function match_source
 
  function login_html($tourl, $context)
  {
 
  } // end function login_html
 
  function logout_html ($tourl)
  {
    require_once QA_INCLUDE_DIR."qa-base.php";
 
    $_SESSION['logout_url'] = $tourl;
    $logout_url = qa_path('auth/logout', null, qa_path_to_root());
    echo('<a href="'.$logout_url.'">'.qa_lang_html('main/nav_logout').'</a>');
  } // end function logout_html
 
} // end class ldap_login
 
Q2A version: 1.5.4

Please log in or register to answer this question.

...