Mobile app version of vmapp.org
Login or Join
Welton855

: Redirect users based on username (LDAP) We have an apache 2.2 install with this config on an Ubuntu 12.04: cat /etc/apache2/sites-enabled/000-default <VirtualHost *:443> ServerAdmin webmaster@localhost

@Welton855

Posted in: #Ldap #Php

We have an apache 2.2 install with this config on an Ubuntu 12.04:

cat /etc/apache2/sites-enabled/000-default
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
AuthType Basic
AuthName "Please provide USERNAME AND PASSWORD!"
AuthBasicProvider ldap
Order allow,deny
Allow from all
AuthLDAPURL "ldap://foo.com/c=uk,ou=bar,o=foo.com?mail"
Require valid-user
Require ldap-attribute dept=4F4623
Require ldap-attribute emailAddress=someone@somewhere.com
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel info
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
</VirtualHost>


It's working great with LDAP auth! We have ldap-utils, php5, apache2.2-common.

Question:

How can we create a page, so for example:

somedomain.com/selectorpage.html


redirects the logged in user to another page based on their username?

So if XY user visits the "selectorpage.html", then it will be redirected immediately to page XY.html. If AB user visits the "selectorpage.html", then it will be redirected immediately to page AB.html. Or are there any apache redirects for this?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Welton855

1 Comments

Sorted by latest first Latest Oldest Best

 

@Lengel546

combining this post with your information, Id suggest you use a php page, instead of an html page in place of selector page.html, and using

$_SERVER['PHP_AUTH_USER']


inside the selector_page.php with either:

switch($_SERVER['PHP_AUTH_USER']){
case "user_a":
$url = "xy.html";
break;
......
case "user_n":
$url = "nn.html";
break;
default:
$url = "ab.html";
break;
}
header("location: $url");


or similar

( you might need to do a mod_rewrite rule to change the selectorpage.html to selectorpage.php if its an external link and not under your control, but it would be better to change the link to point to the php page if its not )

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme