Jump to content

Recommended Posts

Posted

Hi Guys.

 

we have a small php site which is our intranet.

 

on our home page, I want have this line <?php include 'support.php' ?> which is basically a page with a small pop up in the corner with a link to a web page.

 

My question is how can I stop this loading when a student access the page? I only want staff to see the php include.

 

The site is in IIS on server 2008r2.

 

Thanks

 

James

Posted (edited)

Are you using Windows Authentication on IIS? If so, you can use a simple script like this one...

 

$username = $_SERVER['AUTH_USER'];
$split = explode("\\", $username); // Our domain format is STUDENT\User for our staff ones it STAFF\User
$domain = strtolower($split[0]);

if($domain == "staff") // Replace STAFF with whatever format your domain is in, ie STUDENT, STAFF.
{   
// Staff only stuff here
}
else
{
   // Student here
}
?>

 

Sorry hurriedly written.

 

EDIT:

 

Limitations:

 

 

  • Must be using IE

Edited by SovietRussia
Posted

I was looking at windows authentication yesterday. When I enabled it, it would ask me to log in when I navigate to the page but even if I entered my admin details, it would not allow me view the content. How do I automatically pass the username or security group to IIS to allow or disallow this part of the page.

 

Would I include your script on the page that's being displayed or the page I am calling?

 

not had much to do with php until now...

Posted
I was looking at windows authentication yesterday. When I enabled it, it would ask me to log in when I navigate to the page but even if I entered my admin details, it would not allow me view the content. How do I automatically pass the username or security group to IIS to allow or disallow this part of the page.

 

Would I include your script on the page that's being displayed or the page I am calling?

 

not had much to do with php until now...

 

Yeah it will be asking you to login, if you are using IE on a domain PC, it should auto do it for you. You have to login with domain\username style

 

Place this code where you currently include the file.

 

$username = $_SERVER['AUTH_USER'];
$split = explode("\\", $username); // Our domain format is STUDENT\User for our staff ones it STAFF\User
$domain = strtolower($split[0]);

if($domain == "staff") // Replace STAFF with whatever format your domain is in, ie STUDENT, STAFF.
{   
include 'support.php';
}
else
{
   // Student here
}
?>

Posted
ok. And what happens if they want to use chrome/safari/firefox?

 

You cannot use Windows Auth with those browsers, as far as I know - Never looked into it as we use IE here.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...