Jump to content

[SOLVED] Setting Server Variables - I'm a complete noob


mepaco

Recommended Posts

Let me preface this with an admission that I am completely new to PHP and if this is not the appropriate place for such beginner questions, I'm sorry.

 

With that out of the way, I'm trying to work on a project that involves adding functionality to a website.  They have it segmented so that most pages don't require any authentication but one directory (used for all intranet pages) uses a .htaccess file to authenticate users through an LDAP server.  From there, all the pages in that directory look for $_SERVER['REMOTE_USER'] to get the username and populate the page with the proper information.

 

The problem is that I'm not allowed to use their development environment, including the LDAP server.  I got their site up and running on my local box (sans LDAP) and thought that maybe I could work around the authentication by deleting the .htaccess file and creating a fake login page that simply asks for a username and populates $_SERVER['REMOTE_USER'].  This doesn't work at all.  After populating it and redirecting to another page, $_SERVER['REMOTE_USER'] does not appear to be populated.  So, I guess my question is can I set $_SERVER variables, does this seem like it should work, or do I have to try and set up an LDAP server?

 

Thanks,

Patrick

Thank you ... though I was hoping I was just messing something up.  Outside of starting a session, is there any other storage variable that I can use to pass information between pages (without sending them in POST or GET) to sort of emulate the REMOTE_USER variable?

Outside of starting a session, is there any other storage variable that I can use to pass information between pages (without sending them in POST or GET)

 

Not really. A session is your best bet. Armed with your fake login page you could even include something like...

 

<?php

  session_start();

 if (isset($_SESSION['REMOTE_USER'])) {
   $_SERVER['REMOTE_USER'] = $_SESSION['REMOTE_USER'];
 }

?>

 

at the top of every page and ou should be fine to code as normal. (I'de even use the auto_prepend_file php ini directive while developing)

Thank you both.  I think this might not be as bad as I thought.  Every page in the intranet directory includes a particular php file right at the top that simply sets $login = $_SERVER['REMOTE_USER'].  I just did a little experiment and I think that by adding sessions and a line like you describe ($_SERVER['REMOTE_USER'] = $_SESSION['REMOTE_USER']) to the top of this included file, it will solve my problem.  I appreciate the quick help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.