Handle the Win32_GroupUser missing PartCompenent issue

This commit is contained in:
Oran Nadler 2018-05-08 17:05:33 +03:00
parent 588387a263
commit 7af6e6473c
1 changed files with 7 additions and 1 deletions

View File

@ -100,7 +100,13 @@ def fix_wmi_obj_for_mongo(o):
try: try:
value = getattr(o, prop) value = getattr(o, prop)
except wmi.x_wmi: except wmi.x_wmi:
continue # This happens in Win32_GroupUser when the user is a domain user.
# For some reason, the wmi query for PartComponent fails. This table
# is actually contains references to Win32_UserAccount and Win32_Group.
# so instead of reading the content to the Win32_UserAccount, we store
# only the id of the row in that table, and get all the other information
# from that table while analyzing the data.
value = o.properties[prop].value
row[prop] = fix_obj_for_mongo(value) row[prop] = fix_obj_for_mongo(value)