pluginsGLPI / ocsinventoryng

Plugin ocsinventoryng for GLPI
GNU General Public License v2.0
68 stars 52 forks source link

No database connection between OCS & GLPI #312

Closed Demonheart closed 2 years ago

Demonheart commented 2 years ago

I got "Database connection failure" when I try to configure the server.

ocsng

Demonheart commented 2 years ago

Debug say: PHP Warning (2): mysqli::real_connect(): (HY000/1045): Access denied for user 'adminocs'@'localhost' (using password: NO) in /var/www/glpi/src/DBmysql.php at line 240

Have you a solution ?

ajavor commented 2 years ago

Have you set TRACE_DELETED = ON on the OCS server side?

obraz

mitol007 commented 2 years ago

I confirm the problem on GLPI 10.0.0-rc1, OCS 2.9.2 and plugin ocsinventoryng-2.0.0-rc2.

kinfra-vaultwarden commented 2 years ago

Hello,

Debian 11.2 php 7.4 glpi 10.0.0-rc2 ocsinventory NG 2.0.0-rc2

Same problem here. The is no value for ocs_db_passwd in the glpi_plugin_ocsinventoryng_ocsservers glpi table. image

Probably link to this PHP warning : image

rgonzalezmas commented 2 years ago

Hello,

See inc/ocsserver.class.php file, at prepareInputForUpdate($input) I've changed encrypt instead decrypt, and the connection is done... Anybody can't explain this missmatch? A code error...?

 function prepareInputForUpdate($input){

      $adm = new PluginOcsinventoryngOcsAdminInfosLink();
      $adm->updateAdminInfo($input);
      if (isset($input["ocs_db_passwd"]) && !empty($input["ocs_db_passwd"])) {
         $input["ocs_db_passwd"] = rawurlencode(stripslashes($input["ocs_db_passwd"]));
        //$input["ocs_db_passwd"] = (new GLPIKey())->decrypt(stripslashes($input["ocs_db_passwd"]));
        $input["ocs_db_passwd"] = (new GLPIKey())->encrypt(stripslashes($input["ocs_db_passwd"]));
      } else {
         unset($input["ocs_db_passwd"]);
      }

      if (isset($input["_blank_passwd"]) && $input["_blank_passwd"]) {
              $input['ocs_db_passwd'] = '';
      }

      return $input;
   }

After this change , I am able to run the plugin on glpi 10 version and import the OCS computers into glpi asset manager

regards.

tsmr commented 2 years ago

Thanks rgonzalezmas - good game 👍