glpi-project / glpi-agent

GLPI Agent
GNU General Public License v2.0
212 stars 51 forks source link

Current username is not updating in collect data from computer. #687

Closed UnknownA8 closed 1 day ago

UnknownA8 commented 4 weeks ago

Bug reporting acknowledgment

Yes, I read it

Professional support

None

Describe the bug

GLPI not updating current username from computer. Showed only user who was log on while first inventory.

There are no errors anywhere. The agent on the computer show to the correct current user after using the glpi-inventory --partial user command. In GLPI still i have user who was log on while first inventory. In inventory history of computer others application/devices are updating correct.

I based my research on the thread https://github.com/glpi-project/glpi-agent/issues/332

To reproduce

1.Install and configure agent 2.Force inventory

  1. Look at results in GLPI

Expected behavior

Current log on user must be updating in glpi

Operating system

Windows

GLPI Agent version

1.9

GLPI version

10.0.15

GLPIInventory plugin or other plugin version

No response

Additional context

No response

UnknownA8 commented 4 weeks ago

I noticed that the user only updates when I use the command on the computer: C:\Program Files\GLPI-Agent>glpi-agent -f --full.

Using the command C:\Program Files\GLPI-Agent>glpi-agent -f, user is not updating.

g-bougard commented 3 weeks ago

Hi @UnknownA8

when checking on the inventory results, what's the difference regarding the previous and current user between full inventory case and normal case ?

To be honest, my first thought was that's just a server-side problem, but if the user is updated when you force to generate a full inventory, that still can be an agent issue... or maybe a server-side problem. So finding the difference can help to know where the problem should be fixed.

I think you should check the LASTLOGGEDUSER value in HARDWARE section and the USERS section.

Can you eventually share the output you have for these values when using glpi-inventory --partial user command ?

Also, you can set full-inventory-postpone to 0 in registry to always send a full inventory and tell us if this fixes this problem.

SimonTheIman commented 3 weeks ago

Hi @g-bougard , I've tested it too; the alternate username does not get updated after the first inventory. Not even the parameter "--force" does the update. The Output of the partial inventory for "user" prints out my username in both sections "hardware" and "users".

When changing the full-inventory-postpone setting to "0", the alternate username gets successfully updated again.

I have tested both with an empty and filled out (not locked) alternate username field. I guess the agent does not send the alternate username after the first inventory anymore or if the postpone-setting is set to 0.

g-bougard commented 3 weeks ago

Hello @SimonTheIman

Sorry, but I'm really not sure to understand your explanations.

Please provide the concerned changed sections of partial inventory generated with glpi-inventory --partial user to illustrate your purpose.

SimonTheIman commented 3 weeks ago

Hi @g-bougard , see the screenshot below. Both values are displaying my name. But the inventory sent to GLPI does not reflect those values as described before.

Hope this clarifies a bit more.

image

g-bougard commented 3 weeks ago

Just one more question: do you mean the user didn't change between inventories ? This is probably the point I completely missed.

SimonTheIman commented 3 weeks ago

I have tried the following steps:

  1. Fresh inventory for a computer (not in GLPI yet); alternate username is set
  2. Change user on the computer or clear out field alternate username in GLPI
  3. Start inventory on that computer
  4. The field alternate username does not update to the new username

If i change the setting full-inventory-postpone from for example 14 to 0, an repeat those steps, the field alternate username is updated correctly in step 4.

UnknownA8 commented 3 weeks ago

Thank you for your interest.

In my case, it looks like the user field is still the person from the first inventory.

in glpi server inventory we can see user:

image

im log in on this computer on other user:

image

before that i run glpi-agent.bat -f on this notebook and i see last inventory data in this notebook history, but username is not changed.

image

only a full inventory leads to changing the username to the current one, but this is probably not a solution, because it generates more data?

when i use glpi-agent -f --full then username is changing wihtout problem

image

g-bougard commented 3 weeks ago

Okay, I've been able to reproduce.

But this is finally a glpi issue. I opened a new issue for this case here: glpi-project/glpi#17276

g-bougard commented 2 weeks ago

Hi @UnknownA8 and @SimonTheIman

can you try to apply this patch on your GLPI server ? https://github.com/glpi-project/glpi/pull/17299

Indeed you only need to remove 4 lines from l.249 to l.252 in src/Inventory/Asset/MainAsset.php.

And then tell us if this fixes your issue.

SimonTheIman commented 2 weeks ago

Hi @g-bougard, removing those lines made it work again now. But the result of a partial and full inventory differs now.

With a full inventory the alternate username is including the domain of the user (e.g. user@domain); the partial inventory without the --full parameter provided only has the username without the domain (e.g. user).

image

UnknownA8 commented 2 weeks ago

Hi @UnknownA8 and @SimonTheIman

can you try to apply this patch on your GLPI server ? glpi-project/glpi#17299

Indeed you only need to remove 4 lines from l.249 to l.252 in src/Inventory/Asset/MainAsset.php.

And then tell us if this fixes your issue.

I can confirm. after remove these lines username field is updating correct. after press the inventory request from the computer tab

image

thank you!

g-bougard commented 2 weeks ago

Hi @SimonTheIman

my concern is first to know if there's a difference in the inventory. Can you check if there's a difference in your inventory between full inventory and partial regarding user ? For that, you can run this command to generate a full inventory locally:

glpi-inventory --json >full-inventory.json

And this one to generate a user partial inventory:

glpi-inventory --partial user >partial-user-inventory.json

Or you can download them in GLPI from the main asset page each time after running your commands and compare the user parts.

SimonTheIman commented 2 weeks ago

Hi @g-bougard ,

I've generated both inventories an examined them. The users part is exactly the same, both having the same domain and login value.

Maybe the problem is on the side of GLPI itself again, that differs the inventory data from the full to the partial one?

g-bougard commented 2 weeks ago

Can you share a partial inventory example ?

SimonTheIman commented 2 weeks ago

Sure. I have one attached to this comment. partial-user-inventory.json

g-bougard commented 2 weeks ago

Hi @SimonTheIman

okay, I can't see any issue using this file: if "lastloggeduser" in "hardware" section & "users" section are exactly the same in partial & full inventory, GLPI works as expected. So can you check if something is really changing around these sections between inventories.

Anyway, can you check GLPI users for more than one "simon.heim" user ? Also if you're connected to a LDAP, maybe the found simon.heim changes other time if there're more than one. In that case, this is definitively not a inventory issue but a user management one you'll have to figure out yourself or with a GLPI Partner if you own a subscription.

SimonTheIman commented 2 weeks ago

Hi @g-bougard,

i did some more tests on my side and found out that with the file import in GLPI (/front/inventory.conf.php -> "Import from File") the alternate username is set to "username@domain".

But if i run the agent via the CMD (glpi-agent --force) then the alternate username is only set to "username" with the @-domain part missing.

See the Logs of the computer history: image

If i remember correctly, the alternate username also was like "username@domain" when i installed the agent with the "RUNNOW" parameter, but the domain part was missing from every following inventory. This happens to all our devices which are imported via the agent.

g-bougard commented 2 weeks ago

Hi @SimonTheIman

I'm sorry, but you're doing something wrong in the context of a glpi-agent issue: you're just explaining something seems wrong on server-side. You're just sharing server-side side-effect without giving required datas.

If you think you know now the process to reproduce your case, you'll always have to share the datas I need to know if it's a glpi-agent issue or a server issue. So after each time you notice the unexpected change: download the integrated inventory from the asset page (there's an icon for that on the right of the "Inventory information" bar). Then after you have that inventories, check if something is changing regarding "lastloggeduser" in "hardware" section & "users" section like I asked before.

Also when you're saying you're importing a file, you're forgetting to tell how you generate the imported file ?

julian560 commented 1 week ago

After upgrading from GLPI Agent 1.7 to 1.9, it seems that I also encountered this issue of being unable to update users.

g-bougard commented 1 week ago

Hi @julian560

as pointed out in this issue, please apply the patch on GLPI or wait for next glpi release and upgrade it in few weeks.

g-bougard commented 1 day ago

Hello,

I'm closing this issue as glpi-project/glpi#17299 has been merged. GLPI 10.0.16 will be released in few days.

@SimonTheIman after 10.0.16 upgrade, if you still have an issue, please open another issue but for GLPI.