Skip to content
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

OCS imports Alternate Username even if set to "No" in config. Bug identified in code. #363

Open
Mirkk opened this issue Aug 1, 2023 · 0 comments

Comments

@Mirkk
Copy link

Mirkk commented Aug 1, 2023

Dear ocs-glpi community,

We have found a quite severe issue: Alternate Usernames are overwritten even if set to NO in the config.
The reason seems that the next config setting (link_with_user) overwrites that one. Seems to be a copy-paste bug in hardware.class.php, line 215 (if ...["link_with_user"]), where "$updates["contact"] is written instead of "users_id".

It is critical since we write Alternate Usernames by hand, and they are overwritten by OCS each time that an user changed on a computer (not at the first sync).

Versions: all from 2.0.0 rc2 to the actual one.
Here the corrected 2 lines of code (old parts commented)

 if (intval($options['cfg_ocs']["import_general_contact"]) > 0
              && !in_array("contact", $options['computers_updates'])) {
              if (!empty($hardware["USERID"])) {
                  $updates["contact"] = PluginOcsinventoryngOcsProcess::encodeOcsDataInUtf8($is_utf8, $hardware["USERID"]);
              }
          }

          if (intval($options['cfg_ocs']["link_with_user"]) > 0
              # && !in_array("contact", $options['computers_updates'])) {
              && !in_array("users_id", $options['computers_updates'])) {
              if (!empty($hardware["USERID"])) {
                 # **$updates["contact"]** = PluginOcsinventoryngOcsProcess::encodeOcsDataInUtf8($is_utf8, $hardware["USERID"]);
                 $updates["users_id"]** = PluginOcsinventoryngOcsProcess::encodeOcsDataInUtf8($is_utf8, $hardware["USERID"]);
              }
          }

Thank you!
Mirko

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant