Share your image gallery from a server's directory without need for a database thanks to strong encryption. Users can be authenticated via authentication module, e.g. implementing LDAP.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
937 B
24 lines
937 B
8 years ago
|
<?php
|
||
|
$realm = "MY REALM HERE";
|
||
|
$ldaphost = "my.ldap.host";
|
||
|
$base = "dc=my,dc=server,dc=com";
|
||
|
$userbase = "ou=people,".$base;
|
||
|
$groupbase = "ou=group,".$base;
|
||
|
if (!isset($_SERVER['PHP_AUTH_USER'])) {
|
||
|
header('WWW-Authenticate: Basic realm="'.$REALM.'"');
|
||
|
header('HTTP/1.0 401 Unauthorized');
|
||
|
exit;
|
||
|
} else {
|
||
|
$tstusername = ereg_replace('/^[a-z]/', '-', $_SERVER['PHP_AUTH_USER']);
|
||
|
$password = $_SERVER['PHP_AUTH_PW'];
|
||
|
$ldapconn = ldap_connect($ldaphost, 389)
|
||
|
or error_die("connection to LDAP host failed");
|
||
|
ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3)
|
||
|
or error_die("failed to set LDAP protocol version 3");
|
||
|
ldap_start_tls($ldapconn)
|
||
|
or error_die($ldapconn, "cannot start LDAP TLS");
|
||
|
$ldapbind = @ldap_bind($ldapconn, 'uid='.$tstusername.','.$userbase, $password)
|
||
|
or error_die("login failed for $username", '403 Forbidden');
|
||
|
$username = $tstuserbname;
|
||
|
}
|
||
|
?>
|