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

Discussion in 'Python' started by vimuser, Feb 16, 2009.

  1. vimuser

    vimuser Guest

    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?
     
    vimuser, Feb 16, 2009
    #1
    1. Advertising

  2. vimuser

    Tim Golden Guest

    Re: How to enum all the users from a windows domain via pythonwin32net module?

    vimuser wrote:
    > 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?
    > --
    > http://mail.python.org/mailman/listinfo/python-list


    <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
     
    Tim Golden, Feb 16, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S. Hussain Akbar

    Get all domain users

    S. Hussain Akbar, Mar 5, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    380
    S. Hussain Akbar
    Mar 5, 2004
  2. bitshift
    Replies:
    1
    Views:
    555
    bruce barker
    Jun 22, 2007
  3. Bernie Beattie

    WebParts - can you transfer one users choice to all users?

    Bernie Beattie, Sep 6, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    137
    Bernie Beattie
    Sep 6, 2006
  4. Rossco
    Replies:
    0
    Views:
    204
    Rossco
    Sep 27, 2005
  5. c676228
    Replies:
    5
    Views:
    162
    p byers
    Dec 31, 2007
Loading...

Share This Page