-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No inventory number generated when importing computers from ocsngfullsync script #15
Comments
GLPI v 0.90.1. Plugin version 9.1+1.0. OCS Inventory NG plugin version 1.2.1 |
Hi It seems the same when an asset is created by Fusion Inventory. |
Hi @btry , do you know if the preItemAdd function in https://github.com/pluginsGLPI/geninventorynumber/blob/d5e3fc52ff7420c50fea987797e69a9f104fdb6f/inc/generation.class.php#L84 is called before every itemadd (even the ones from OCS Inventory and FusionInventory) ? Or should a hook like "autoinventory_information" should be added for this plugins to work? If this function is called even if it's a plugin that add the item, I suspect that both plugins (OCS and FusionInventory) are just missing rights to CREATE and UPDATE fron those 2 lines : Session::haveRight("plugin_geninventorynumber", CREATE)
Session::haveRight("plugin_geninventorynumber", UPDATE) geninventorynumber/inc/generation.class.php Line 116 in d5e3fc5
Can you point me if my suspicions are in the right direction? Thanks |
Hi preItemAdd is a hook. You will find the hook definition in this plugin in hook.php. To find when the hook is called, read CommonDBTM::add(). https://github.com/glpi-project/glpi/blob/9.5/bugfixes/inc/commondbtm.class.php#L1120 |
After some more troubleshooting :
Is-it a normal behavior for fusionInventory not to get detected as a commandline ? |
Hi You should check how the OCS to FI script do the import. Maybe it issues an HTTP request to FI. An easy way is to check the access log of the http server in real time, then run the script. |
Yes the fusionInventory agent (and I'm pretty sure OSC does the same) are sending HTTP POST requests to FusionInventory plugins...
Since the device is added directly by the "Plugin_Fusioninventory" user once the inventory is submitted by http request, I think we could add another if and verify that the user is not it before throwing the error... That should fix the issue... I've already tested with commenting this check and the inventorynumber gets generated correctly on computer creation from FusionInventory... I'll have a look on monday and submit the fix for approval |
Changing this line for the following fix it for us.... I don't know if you want to submit this change to the community, it should also fix it for OCS Inventory since it uses FusionInventory for GLPI plugins... I not sure if the OP @scoudeville could test if it fix for him too (4 years later....)
|
Hi You may also want to check if the user Plugin_FusionInventory has a profile and simply grant the right to generate a inventory number. This would avoid to hard code a username. |
That was my first thought because I too hate to put a hardcoded string name inside code but this account has no profile associated with it by default. I've associated the "super-admin" profile temporarily for testing (which already have CREATE and UPDATE rights on this plugins) but it did not seem to pass the Session:haveRight() check and was the reason I was asking if it's normal that it's not detected as a commandLine... For info :
The other thing is, since it's a function user created by the FusionInventory plugins itself, and that user normally don't "log-in" in GLPI and we don't have control over it's password, I don't want to give it lots of rights so if we would be to find a fix for the "haveRight()" check, we would have to create a profile manually with restricted rights only for generation of the inventoryNumber..... Not convinces it would be user friendly..... Your thoughts? |
PS Thanks @btry , not sure we say it frequently enough but you really do a great works for this tool ;) |
The right to relate an inventory number is specific to the plugin, then super admins don't have this right by default, except if the plugin has logic to add this right at installation time. Adding a profile to the fusion inventory user might not work as I guess the plugin artificially configure the session to do some kind of fake login, just enough to let glpi believe someone is logged in, without setting up an active profile. If I'm wrong, then tuning the rights should be sufficient, and ensuring that the account is disabled in GLPI should prevent anyone to login. An testing instance of glpi + FI are necessary to validate the inability to login, after setting the password to some known value. |
For infos :
I might investigate further later when I'll have some spare time but don't really have time this week and I won't be messing too much on our live instance. We already have a test instance but no devices configured to send the fusioninventory to it yet. The hard-coded fix does it for us for the moment because we needed this inventoryNumber automatically generated for my homemade plugins to be able to print asset labels on our devices. (might publish it later after lots of cleaning...) Thanks again |
Hello, unfortunately we still have this issue with our GLPI 9.5.6, Inventory Number Generator Plugin 2.5.1 and OCS Inventory NG Plugin 1.7.3. Is there any other workaround for this or will this issue be fixed in the near future? Thanks, |
I was able to get this to work with OCS inventory NG using the patch of 'geninventorynumber/inc/generation.class.php' that fralla2 mentioned above, just replacing the hardcoded username like this: if ((!Session::haveRight("plugin_geninventorynumber", CREATE)) && $_SESSION["glpiname"] != 'ocsinventoryng') { |
I'm using ocsngfullsync script to automatically import computers from OCS to GLPI.
Since I used manual sync with OcsInventory NG plugin, there was no problems.
Now, computers are correctly imported by user "ocsinventoryng" and no inventory number is created. I have to select new computers, Mass Action, and generate a new one to get to success.
I've already created a "ocsinventoryng" local user in GLPI, with "super-admin" profile on root entity (and recursive) , but it doesn't help.
I don't think it's a OcsInventory NG plugin problem because it's using correct GLPI method to insert computers, like in manual sync process.
I think GenInventoryNumber plugin doesn't react if it's loaded from CLI, but can't get any log to help.
The text was updated successfully, but these errors were encountered: