X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Ffunctions_setup.inc;h=cabcbbdb1c9128883b402e4fe900c3d2757a03c0;hb=b57c77d36fbcf682603db5e7c247d2b6ff6ccee2;hp=a558666355cbac4caf995620808917ba5211362b;hpb=24515ce15a7012aae8a2a832b0ae171c47b99e00;p=gosa.git diff --git a/include/functions_setup.inc b/include/functions_setup.inc index a55866635..cabcbbdb1 100644 --- a/include/functions_setup.inc +++ b/include/functions_setup.inc @@ -32,28 +32,13 @@ function view_schema_check($table) function is_schema_readable($server, $admin, $password) { - $ds= ldap_connect ($server); - if (!$ds) { - return (false); - } - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - $r= ldap_bind ($ds, $admin, $password); - - /* Get base to look for schema */ - $sr = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry")); - $attr= @ldap_get_entries($ds,$sr); - if (!isset($attr[0]['subschemasubentry'][0])){ - return (false); - } + $ldap = new LDAP($admin,$password,$server); + $tmp = $ldap->get_objectclasses(); - $nb= $attr[0]['subschemasubentry'][0]; - $objectclasses= array(); - $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses")); - $attrs= ldap_get_entries($ds,$sr); - if (!isset($attrs[0])){ - return (false); + if(count($tmp)){ + return(true); } - return(true); + return(false); } function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false) @@ -92,35 +77,13 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false "goFaxServer" => array("version" => "2.4", "class" => "gofaxAccount","file" => "gofax.schema"), ); - /* Build LDAP connection */ - $ds= ldap_connect ($server); - if (!$ds) { - return (array(array("msg" => _("Can't bind to LDAP. No schema check possible!"), "status" => FALSE))); - } - ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3); - $r= ldap_bind ($ds, $admin, $password); - - /* Get base to look for schema */ - $sr = @ldap_read ($ds, NULL, "objectClass=*", array("subschemaSubentry")); - $attr= @ldap_get_entries($ds,$sr); - if (!isset($attr[0]['subschemasubentry'][0])){ + /* Get objectclasses */ + $ldap = new LDAP($admin,$password, $server); + $objectclasses = $ldap->get_objectclasses(); + if(count($objectclasses) == 0){ return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE))); } - /* Get list of objectclasses */ - $nb= $attr[0]['subschemasubentry'][0]; - $objectclasses= array(); - $sr= ldap_read ($ds, $nb, "objectClass=*", array("objectclasses")); - $attrs= ldap_get_entries($ds,$sr); - if (!isset($attrs[0])){ - return (array(array("msg" => _("Can't get schema information from server. No schema check possible!"), "status" => FALSE))); - } - foreach ($attrs[0]['objectclasses'] as $val){ - $name= preg_replace("/^.* NAME\s+\(*\s*'([^']+)'\s*\)*.*$/", '\\1', $val); - if ($name != $val){ - $objectclasses[$name]= $val; - } - } /* Walk through objectclasses and check if they are needed or not */ foreach ($required_classes as $key => $value){ if (isset($value['class'])){ @@ -247,6 +210,16 @@ function schema_check($server, $admin, $password, $aff=0,$CalledByIndexPhP=false $affich['nagioscontact']['status']= true; } + if ((!isset($objectclasses['apple-user'])) || (!isset($objectclasses['mount'])) ){ + $messages['netatalk']['msg']= _("Support for netatalk disabled, no schema seems to be installed"); + $affich['netatalk']['msg']= $messages['netatalk']['msg']."