Hi,

I've been experimenting with the wmi module and so far everything is
working great, but I'm having an issue with the Win32_LoggedOnUser
class. I can seem to access it's properties. When I run the code in
debug I can see the information I want is being stored in the object
but all attempts to access it throw an error.

Example:
c = wmi.WMI (computer='CCBH-01')

ls = c.Win32_LogonSession()
for l in ls:
  print l.LogonId

u = c.Win32_LoggedOnUser()

Now in my debugger ls hold a list of objects, type of each object is
None, but the value is _wmi_object containing a Win32_LogonSession
object which allows the for loop and print to work.

In the debugger display it looks like this:
Name       Type            Value
ls               list
      [0]       None           <_wmi_object: \\CCBH-01\root\cimv2:
                                        Win32_LogonSession.LogonId="999">
{repeated for all member of the list}

Now in the case of u, it looks like this in the debugger:
Name       Type            Value
u               list
   [0]          None          <_wmi_object: \\CCBH-01\root\cimv2:
                                        Win32_LoggedOnUser.Antecedent="\
                                        \\\.\ \root\ \cimv2:
                                      Win32_Account.Domain=\"CCBH-01\",
                                      Name= \"SYSTEM \"",Dependent="\\
                                      \ \. \ \root \
                                      \cimv2:Win32_LogonSession.LogonId=
                                        \"999 \"">

In my thinking I should have been able to access the Antecedent
property which would have return a Win32_Account object and then been
able to access the Name property of that, such as;

account = u[0].Antecedent
print account.Name

The above throws this error on the first line:
x_wmi: <x_wmi: Unexpected COM Error (-2147217406, 'OLE error
0x80041002', None, None)>

If I try and access the LogonId property I get an AttributeError.

I have a work around of casting the values as a str() then parsing the
string to get the values I need, but I'd really prefer to access the
objects retrieved directly.

I hope this makes since.

Thanks!

Rod
-- 
"Every time I think of pushing you down the stairs, I lick my lips"
  - "Bones In the Water"
     Battle Of Mice
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to