[python-win32] Creating users

Tim Roberts timr at probo.com
Wed Mar 8 18:53:09 CET 2006


On Tue, 7 Mar 2006 16:39:13 -0500, "James Carroll" <mrmaple at gmail.com>
wrote:

>Hi I'm looking at maybe using:
>
> win32net.NetUserAdd(server, 1, d)
>
>to create user directories under Documents and Settings on the local
>machine, but don't know what they want for passwords.  I also don't
>know if the users I want to create already have an account on their
>campus domain controller.
>
>Is there a way to add the user given just the username, and have it do
>the right thing (use the domain controller's account or a local
>account if that doesn't exist) most of the time?
>
>I'm also having trouble with
>  info = win32net.NetUserGetInfo(server, userName, 3)
>No matter what username I give it, it can't find that user.
>
>Also, Enumerating users always returns an empty set, even though I
>have about 6 users set up on my machine.
>
>Could I have a broken install?
>  
>


I doubt it.  The most obvious question is, are you running as an
administrator?  Or, if you are trying to fetch from a domain controller,
are you a domain administrator?  Unprivileged users cannot access user
information.

>>> import win32net
>>> from pprint import pprint
>>> i = win32net.NetUserEnum('',0,0)
>>> pprint(i)
([{'name': u'ACTUser'},
  {'name': u'Administrator'},
  {'name': u'ASPNET'},
  {'name': u'Guest'},
  {'name': u'HelpAssistant'},
  {'name': u'SQLDebugger'},
  {'name': u'SUPPORT_38898898'},
  {'name': u'timr'},
  {'name': u'VUSR_TIMR2'}],
 9,
 0)
>>>

By the way, I don't believe that NetUserAdd will actually create profile
directories.  It creates the user names and remembers their information,
but in my experience, the profile directory does not get created until
the user actually logs in for the first time.  This is, of course, a bit
inconvenient if you want to pre-populate their desktop.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list