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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.