translation update, minor fixes
This commit is contained in:
parent
00df6d3833
commit
301baa028a
142
lam/lib/ldap.inc
142
lam/lib/ldap.inc
|
@ -28,87 +28,83 @@ include_once("config.inc");
|
||||||
// manages connection to LDAP and several helper functions
|
// manages connection to LDAP and several helper functions
|
||||||
class Ldap{
|
class Ldap{
|
||||||
|
|
||||||
// object of Config to access preferences
|
// object of Config to access preferences
|
||||||
var $conf;
|
var $conf;
|
||||||
|
|
||||||
// server handle
|
// server handle
|
||||||
var $server;
|
var $server;
|
||||||
|
|
||||||
// LDAP username and password used for bind
|
// LDAP username and password used for bind
|
||||||
var $username;
|
var $username;
|
||||||
var $password;
|
var $password;
|
||||||
|
|
||||||
// Arrays that contain LDAP attributes and their descriptions which are translated
|
// Arrays that contain LDAP attributes and their descriptions which are translated
|
||||||
var $ldapUserAttributes;
|
var $ldapUserAttributes;
|
||||||
var $ldapGroupAttributes;
|
var $ldapGroupAttributes;
|
||||||
var $ldapHostAttributes;
|
var $ldapHostAttributes;
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
// $config has to be an object of Config (../config/config.php)
|
// $config has to be an object of Config (../config/config.php)
|
||||||
function Ldap($config) {
|
function Ldap($config) {
|
||||||
if (is_object($config)) $this->conf = $config;
|
if (is_object($config)) $this->conf = $config;
|
||||||
else { echo _("Ldap->Ldap failed!"); exit;}
|
else return false;
|
||||||
// construct arrays with known LDAP attributes
|
// construct arrays with known LDAP attributes
|
||||||
$this->ldapUserAttributes = array (
|
$this->ldapUserAttributes = array (
|
||||||
"uid" => _("User ID"),
|
"uid" => _("User ID"),
|
||||||
"uidNumber" => _("UID Number"),
|
"uidNumber" => _("UID number"),
|
||||||
"gidNumber" => _("GID Number"),
|
"gidNumber" => _("GID number"),
|
||||||
"cn" => _("User Name"),
|
"cn" => _("Username"),
|
||||||
"host" => _("Allowed Hosts"),
|
"host" => _("Allowed hosts"),
|
||||||
"givenName" => _("First Name"),
|
"givenName" => _("First name"),
|
||||||
"sn" => _("Last Name"),
|
"sn" => _("Last name"),
|
||||||
"homeDirectory" => _("Home Directory"),
|
"homeDirectory" => _("Home directory"),
|
||||||
"loginShell" => _("Login Shell"),
|
"loginShell" => _("Login shell"),
|
||||||
"mail" => _("E-Mail"),
|
"mail" => _("E-Mail"),
|
||||||
"gecos" => _("Description")
|
"gecos" => _("Description")
|
||||||
);
|
);
|
||||||
$this->ldapGroupAttributes = array (
|
$this->ldapGroupAttributes = array (
|
||||||
"cn" => _("Group Name"),
|
"cn" => _("Group name"),
|
||||||
"gidNumber" => _("GID Number"),
|
"gidNumber" => _("GID number"),
|
||||||
"memberUID" => _("Group Members"),
|
"memberUID" => _("Group members"),
|
||||||
"member" => _("Group Member DNs"),
|
"member" => _("Group member DNs"),
|
||||||
"description" => _("Group Description")
|
"description" => _("Group description")
|
||||||
);
|
);
|
||||||
$this->ldapHostAttributes = array (
|
$this->ldapHostAttributes = array (
|
||||||
"uid" => _("Host Username"),
|
"uid" => _("Host username"),
|
||||||
"cn" => _("Host Name"),
|
"cn" => _("Host name"),
|
||||||
"rid" => _("RID (Windows UID)"),
|
"rid" => _("RID (Windows UID)"),
|
||||||
"description" => _("Host Description")
|
"description" => _("Host description")
|
||||||
);
|
);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// connects to the server using the given username and password
|
// connects to the server using the given username and password
|
||||||
// $base is optional and specifies the root from where to search for entries
|
// $base is optional and specifies the root from where to search for entries
|
||||||
// if connect succeeds the server handle is returned
|
// if connect succeeds the server handle is returned
|
||||||
function connect($user, $passwd) {
|
function connect($user, $passwd) {
|
||||||
// close any prior connection
|
// close any prior connection
|
||||||
@$this->close();
|
@$this->close();
|
||||||
// do not allow anonymous bind
|
// do not allow anonymous bind
|
||||||
if ((!$user)||($user == "")||(!$passwd)) {
|
if ((!$user)||($user == "")||(!$passwd)) {
|
||||||
echo ("<html><head><title></title>");
|
return false;
|
||||||
echo ("<link rel=\"stylesheet\" type=\"text/css\" href=\"../style/layout.css\"></head><body>");
|
}
|
||||||
StatusMessage("ERROR", "", _("No username was specified or password is empty!"));
|
// save password und username encrypted
|
||||||
echo ("<br><br><a href=\"login.php\">" . _("Back to Login") . "</a></body></html>");
|
$this->encrypt($user, $passwd);
|
||||||
exit;
|
$this->server = @ldap_connect($this->conf->get_ServerURL());
|
||||||
}
|
if ($this->server) {
|
||||||
// save password und username encrypted
|
// use LDAPv3
|
||||||
$this->encrypt($user, $passwd);
|
ldap_set_option($this->server, LDAP_OPT_PROTOCOL_VERSION, 3);
|
||||||
|
$bind = @ldap_bind($this->server, $user, $passwd);
|
||||||
$this->server = @ldap_connect($this->conf->get_ServerURL());
|
if ($bind) {
|
||||||
if ($this->server) {
|
// return server handle
|
||||||
// use LDAPv3
|
return $this->server;
|
||||||
ldap_set_option($this->server, LDAP_OPT_PROTOCOL_VERSION, 3);
|
}
|
||||||
$bind = @ldap_bind($this->server, $user, $passwd);
|
}
|
||||||
if ($bind) {
|
}
|
||||||
// return server handle
|
|
||||||
return $this->server;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// closes connection to server
|
// closes connection to server
|
||||||
function close() {
|
function close() {
|
||||||
ldap_close($this->server);
|
if (isset($this->server)) ldap_close($this->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
// searches LDAP for a specific user name
|
// searches LDAP for a specific user name
|
||||||
|
|
Loading…
Reference in New Issue