How to enum all the users from a windows domain via python win32netmodule?

V

vimuser

I tried the command "net user /DOMAIN" in windows console(cmd.exe),
and it showed me all the usernames in my domain without any problems.
But when I tried it in python with these commands :
info=win32net.NetUserEnum("DOMAIN_NAME",1),
info=win32net.NetUserEnum(r"\\DOMAIN_NAME",1),and
info=win32net.NetUserEnum("\\\\DOMAIN_NAME",1), I all got the System
Error 53 (The network path was not found) .

What should I do, if I intend to enum all the users from a windows
domain via python win32net module?
 
T

Tim Golden

vimuser said:
I tried the command "net user /DOMAIN" in windows console(cmd.exe),
and it showed me all the usernames in my domain without any problems.
But when I tried it in python with these commands :
info=win32net.NetUserEnum("DOMAIN_NAME",1),
info=win32net.NetUserEnum(r"\\DOMAIN_NAME",1),and
info=win32net.NetUserEnum("\\\\DOMAIN_NAME",1), I all got the System
Error 53 (The network path was not found) .

What should I do, if I intend to enum all the users from a windows
domain via python win32net module?

<code>

import win32net
import win32netcon

dc = win32net.NetGetAnyDCName (None, None)

resume = 0
while 1:
(_users, total, resume) = \
win32net.NetUserEnum (
dc,
3,
win32netcon.FILTER_NORMAL_ACCOUNT,
resume,
win32netcon.MAX_PREFERRED_LENGTH
)
for _user in _users:
print _user['name'], _user['home_dir'], _user['profile']
break
if not resume:
break


</code>

TJG
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top