ocsinventoryng
ocsinventoryng copied to clipboard
OCS imports Alternate Username even if set to "No" in config. Bug identified in code.
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