index 65285a6559f6599687081877e6146dda7479901e..6aa0277886795d0f9b4199f8287000500a6e4527 100644 (file)
--- a/include/class_config.inc
+++ b/include/class_config.inc
/* Keep a copy of the current deparment list */
var $departments= array();
var $idepartments= array();
/* Keep a copy of the current deparment list */
var $departments= array();
var $idepartments= array();
+ var $adepartments= array();
function config($filename, $basedir= "")
{
function config($filename, $basedir= "")
{
$this->currentLocation= $name;
/* Add location elements */
$this->currentLocation= $name;
/* Add location elements */
- $this->data['LOCATIONS'][$name]= $attrs;
- }
+ $this->data['LOCATIONS'][$name]= $attrs;
+ }
break;
/* Handle referral tags */
break;
/* Handle referral tags */
/* Check for connection */
if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
/* Check for connection */
if (is_null($this->ldap) || (is_int($this->ldap) && $this->ldap == 0)){
+ $smarty= get_smarty();
print_red (_("Can't bind to LDAP. Please contact the system administrator."));
print_red (_("Can't bind to LDAP. Please contact the system administrator."));
- echo $_SESSION['errors'];
- exit;
+ $smarty->display (get_template_path('headers.tpl'));
+ echo '<body style="background-image:none">'.$_SESSION['errors'].'</body></html>';
+ exit();
}
if (!isset($_SESSION['size_limit'])){
}
if (!isset($_SESSION['size_limit'])){
/* Get asterisk servers */
$ldap->cd ($this->current['BASE']);
/* Get asterisk servers */
$ldap->cd ($this->current['BASE']);
- $ldap->search ("(objectClass=goGlpiServer)");
+ $ldap->search ("(&(objectClass=goGlpiServer)(cn=*)(goGlpiAdmin=*)(goGlpiDatabase=*))",array("cn","goGlpiPassword","goGlpiAdmin","goGlpiDatabase"));
if ($ldap->count()){
$attrs= $ldap->fetch();
if ($ldap->count()){
$attrs= $ldap->fetch();
+ if(!isset($attrs['goGlpiPassword'])){
+ $attrs['goGlpiPassword'][0] ="";
+ }
$this->data['SERVERS']['GLPI']= array(
'SERVER' => $attrs['cn'][0],
'LOGIN' => $attrs['goGlpiAdmin'][0],
$this->data['SERVERS']['GLPI']= array(
'SERVER' => $attrs['cn'][0],
'LOGIN' => $attrs['goGlpiAdmin'][0],
$ldap->search ("(&(objectClass=goShareServer)(goExportEntry=*))");
while ($attrs= $ldap->fetch()){
for ($i= 0; $i<$attrs["goExportEntry"]["count"]; $i++){
$ldap->search ("(&(objectClass=goShareServer)(goExportEntry=*))");
while ($attrs= $ldap->fetch()){
for ($i= 0; $i<$attrs["goExportEntry"]["count"]; $i++){
- $path= preg_replace ("/\s.*$/", "", $attrs["goExportEntry"][$i]);
+ if(!preg_match('/^[^|]+\|[^|]+\|NFS\|.*$/', $attrs["goExportEntry"][$i])){
+ continue;
+ }
+ $path= preg_replace ("/^[^|]+\|[^|]+\|[^|]+\|[^|]+\|([^|]+).*$/", '\1', $attrs["goExportEntry"][$i]);
$tmp[]= $attrs["cn"][0].":$path";
}
}
$this->data['SERVERS']['NFS']= $tmp;
$tmp[]= $attrs["cn"][0].":$path";
}
}
$this->data['SERVERS']['NFS']= $tmp;
-
/* Load Terminalservers */
$ldap->cd ($this->current['BASE']);
$ldap->search ("(objectClass=goTerminalServer)");
/* Load Terminalservers */
$ldap->cd ($this->current['BASE']);
$ldap->search ("(objectClass=goTerminalServer)");
}
/* Ldap Server */
}
/* Ldap Server */
- $this->data['SERVERS']['LDAP']= array("default");
+ $this->data['SERVERS']['LDAP']= array();
$ldap->cd ($this->current['BASE']);
$ldap->search ("(objectClass=goLdapServer)");
while ($attrs= $ldap->fetch()){
$ldap->cd ($this->current['BASE']);
$ldap->search ("(objectClass=goLdapServer)");
while ($attrs= $ldap->fetch()){
}
}
}
}
+
+ function get_departments($ignore_dn= "")
+ {
+ global $config;
+
+ /* Initialize result hash */
+ $result= array();
+ $administrative= array();
+ $result['/']= $this->current['BASE'];
+
+ /* Get list of department objects */
+ $ldap= $this->get_ldap_link();
+ $ldap->cd ($this->current['BASE']);
+ $ldap->search ("(objectClass=gosaDepartment)", array("ou", "objectClass", "gosaUnitTag"));
+ while ($attrs= $ldap->fetch()){
+ $dn= $ldap->getDN();
+
+ /* Save administrative departments */
+ if (in_array_ics("gosaAdministrativeUnit", $attrs['objectClass']) &&
+ isset($attrs['gosaUnitTag'][0])){
+ $administrative[$dn]= $attrs['gosaUnitTag'][0];
+ }
+
+ if ($dn == $ignore_dn){
+ continue;
+ }
+
+ /* Only assign non-root departments */
+ if ($dn != $result['/']){
+ $result[convert_department_dn($dn)]= $dn;
+ }
+ }
+
+ $this->adepartments= $administrative;
+ $this->departments= $result;
+ }
+
+
function make_idepartments($max_size= 28)
{
global $config;
function make_idepartments($max_size= 28)
{
global $config;
function getShareServerList()
{
$ldap= $this->get_ldap_link();
function getShareServerList()
{
$ldap= $this->get_ldap_link();
- $a_res = $ldap->search("(objectClass=goShareServer)",array("goExportEntry","cn"));
+ $a_res = $ldap->search("(&(objectClass=goShareServer)(goExportEntry=*))",array("goExportEntry","cn"));
$return= array();
while($entry = $ldap->fetch($a_res)){
if(isset($entry['goExportEntry']['count'])){
$return= array();
while($entry = $ldap->fetch($a_res)){
if(isset($entry['goExportEntry']['count'])){