2010-02-28 13:04:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function authenticate($username,$password)
|
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
$ds=@ldap_connect($config['auth_ldap_server'],$config['auth_ldap_port']);
|
|
|
|
if ($ds)
|
|
|
|
{
|
2010-03-01 01:23:37 +00:00
|
|
|
if ($config['auth_ldap_version'])
|
|
|
|
{
|
|
|
|
ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, $config['auth_ldap_version']);
|
|
|
|
}
|
2010-02-28 13:04:07 +00:00
|
|
|
if (ldap_bind($ds, $config['auth_ldap_prefix'] . $username . $config['auth_ldap_suffix'], $password))
|
|
|
|
{
|
|
|
|
if (!$config['auth_ldap_group'])
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ldap_compare($ds,$config['auth_ldap_group'],'memberUid',$username))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
# FIXME return a warning that LDAP couldn't connect?
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-06 00:00:05 +00:00
|
|
|
function passwordscanchange()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function changepassword($username,$newpassword)
|
|
|
|
{
|
|
|
|
# Not supported (for now)
|
|
|
|
}
|
2010-03-06 01:10:05 +00:00
|
|
|
|
|
|
|
function auth_usermanagement()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function adduser($username, $password, $level, $email = "", $realname = "")
|
|
|
|
{
|
|
|
|
# Not supported
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
function user_exists($username)
|
|
|
|
{
|
|
|
|
return 0; # FIXME to be implemented
|
|
|
|
}
|
|
|
|
|
2010-03-06 01:15:52 +00:00
|
|
|
function get_userlevel($username)
|
|
|
|
{
|
|
|
|
# FIXME should come from LDAP
|
|
|
|
$sql = "SELECT level FROM `users` WHERE `username`='".mres($username)."'";
|
2010-03-06 01:19:06 +00:00
|
|
|
$row = mysql_fetch_array(mysql_query($sql));
|
2010-03-06 01:15:52 +00:00
|
|
|
return $row['level'];
|
|
|
|
}
|
2010-03-06 01:22:09 +00:00
|
|
|
|
|
|
|
function get_userid($username)
|
|
|
|
{
|
|
|
|
# FIXME should come from LDAP
|
|
|
|
$sql = "SELECT user_id FROM `users` WHERE `username`='".mres($username)."'";
|
|
|
|
$row = mysql_fetch_array(mysql_query($sql));
|
|
|
|
return $row['user_id'];
|
|
|
|
}
|
|
|
|
|
2010-02-28 13:04:07 +00:00
|
|
|
?>
|