I need to get a list of all machines in a (Windows-)domain. So I used
as described in the ActiveState Python Documentation
win32net.NetServerEnum('',100,win32netcon.SV_TYPE_ALL,'domain-x') to
get this list from the PDC. But the result is only a list of all
machines which are logged-in. What I really need is a list of ALL
machines - taht means also the machines which belong to this domain,
but are logged-off (or simply switched-off).
A colleague did it in Perl with this code:
Win32::AdminMisc::GetMachines( $dc, UF_WORKSTATION_TRUST_ACCOUNT,
\%wkslist, "" );
This retrieves a whole list of the machines of a domain.
How can I do this in Python???
Thanks a lot for your response!
Dirk
Using wmi is a possibility (maybe Win32_GroupUser). Search
for my recent posting in c.l.p "Tip: Windows internals using wmi".
Colin Brown
PyNZ
I'm a little surprised to find that this call returns only machine
logged-on (and do you, by the way, mean "switched on" or really
"logged on" - ie with someone's username active on the machine?).
However, see if this thread from the Python win32 group is of any use
to you.
http://aspn.activestate.com/ASPN/Mail/Message/1785767
TJG
Thanks for the link! I tried this code once before, but I got an error
because of this
"WinNT:" in the code. But on tuesday I will try again.I don't know if I also
got machines which are only switched on - but that'spossible (I will test
this as well on tuesday. Now I start into myextra-long weekend - yet :-) ).
Dirk
Just in case it helps, there was a follow-up discussion which somehow
became detached from its thread:
http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/1786718
although that doesn't address problems with WinNT: which should work,
I think, on anything from NT upwards (not on Win9x). We don't use AD
here, and it works on my Win2K machine.
TJG
> I need to get a list of all machines in a (Windows-)domain.
If an Active Directory domain then you could use;
import win32com.client
def do_onecontainer(Container):
for oneobject in Container:
if oneobject.Class.lower()=='computer':
print oneobject.cn
if oneobject.Class.lower()=="organizationalunit" or \
oneobject.Class.lower()== "container":
do_onecontainer(oneobject)
startContainer=win32com.client.GetObject("LDAP://DC=mydomain,DC=local")
do_onecontainer(startContainer)
--
___
|im ---- ARM Powered ----
No, thank you. It's not an AD-domain - that's what we are preparing...
Dirk
Thank you!!! That works :-)
Now I can care about the coming up next problems... ;-)
Dirk