Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Auto Login with $_SERVER['REMOTE_USER']

edited September 2008 in Vanilla 1.0 Help
Hi: I am using LDAP Authentication with a class mentioned in http://lussumo.com/community/discussion/3340/active-directory-integration/. It's working for me. My question is: Is there a way I can turn off the Sign-in and sign-out process? I would like users to be logged in the moment they come in, based on $_SERVER['REMOTE_USER']. This is secure server and they always have to log in to access the forum, so this variable will always be there. Help Please

Comments

  • Options
    I have a plugin that integrates amember with vanilla that does something similar. Unfortunately I can't post it here because it's commercial code, but looking at how it works it looks like the main thing it does is on these lines: session_start(); $_SESSION["LussumoUserID"]=$yourUser; So probably something like: $_SESSION["LussumoUserID"]=$_SERVER['REMOTE_USER']; ...might work.
  • Options
    Thanks. But where do I set that variable? init_vanilla.php?
  • Options
    In the end I managed it. Here's what I did. Please let me know if I should change it or if it's ok.

    // Start a session if required username/password exist in the system
    function Start(&$Context, $Authenticator, $UserID = '0') {


    $UserManager = false;

    // If the UserID is not explicitly defined (ie. by some vanilla-based login module),
    // retrieve the authenticated UserID from the Authenticator module.
    $this->UserID = ForceInt($UserID, 0);
    if ($this->UserID == 0) $this->UserID = $Authenticator->GetIdentity();

    // Now retrieve user information
    if ($this->UserID > 0) {
    $UserManager = $Context->ObjectFactory->NewContextObject($Context, 'UserManager');
    $this->User = $UserManager->GetSessionDataById($this->UserID);

    // If the session data retrieval failed for some reason, dump the user
    if (!$this->User) {
    $this->User = $Context->ObjectFactory->NewContextObject($Context, 'User');
    $this->User->Clear();
    $this->UserID = 0;
    }
    } else {
    $this->User = $Context->ObjectFactory->NewContextObject($Context, 'User');
    $this->User->Clear();
    $this->AuthoAuthenticate($Context, $Authenticator, $UserID );

    }
    }
    function AutoAuthenticate(&$Context, $Authenticator, $UserID = '0') {
    $username = str_replace('MYNET\\','',$_SERVER['REMOTE_USER']);
    $Authenticator->Authenticate($username,TRUE);
    $this->Start($Context, $Authenticator,$UserID);
    }
  • Options
    Authenticate() sets the session variable so that looks like it ought to work.
  • Options
    It's working and no problems so far. Thanks for verification (assures me that I am doing it right) :)
  • Options
    Nice work! Where did you put this code, and in what circumstance do you call it? Is it in a Vanilla source file?
This discussion has been closed.