[python-win32] Re: Creating users
Roger Upole
rwupole at msn.com
Wed Mar 8 13:54:25 CET 2006
James Carroll 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.
NetUserAdd actually creates a new user, rather than creating a profile.
The profile, which is what's stored in Documents and Settings, will
be created (or copied from a server in the case of a roaming profile)
when the account is first logged on . You can specify
the location using the 'profile' member of USER_INFO_3 or 4.
>
> 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.
Are you sure you're specifying the correct server ? Use None to
mean the local machine. Also, how are you specifying the username ?
eg a bare username, NT-style 'domain\username', Active Directory
syntax 'username at domain' etc.
>
> Also, Enumerating users always returns an empty set, even though I
> have about 6 users set up on my machine.
>
NetUserEnum is a little tricky to use, can you post your code ?
hth
Roger
More information about the Python-win32
mailing list