win32net.NetGroupAddUser

logistix logistix at zworg.com
Tue Dec 3 20:12:43 EST 2002


kcollins15 at cfl.rr.com (kay c) wrote in message news:<b24d403d.0212021252.75b55917 at posting.google.com>...
> Need help with win32net.NetGroupAddUser.  I used Mark Hammond sample
> code in Python Programming on Win32. I then added one line to add the
> newuser to a group.
> def CreateUserAndShare(userName, fullName):
>     homeDir = "%s\\%s" % (serverName, userName)
>     # Create user data in information level 3 (PyUSER_INFO_3) format.
>     userData = {}
>     userData['name'] = userName
>     userData['full_name'] = fullName
>     userData['password'] = userName
>     userData['flags'] = win32netcon.UF_NORMAL_ACCOUNT |
> win32netcon.UF_SCRIPT
>     userData['priv'] = win32netcon.USER_PRIV_USER
>     userData['home_dir'] = homeDir
>     userData['home_dir_drive'] = "P:"
>     userData['primary_group_id'] =
> ntsecuritycon.DOMAIN_GROUP_RID_USERS
>     userData['password_expired'] = 1 # User must change password next
> logon.
>     
>     # Create the user
>     win32net.NetUserAdd(serverName, 3, userData)
>     win32net.NetGroupAddUser(serverName, "Administrator", userName)
> 
> This is my error:
> pywintypes.api_error: (2220, 'NetGroupAddUser', 'The group name could
> not be fou
> nd.')
> Any help will be greatly appreciated..
> Thanks,
> kc

Unless you're doing something really crazy, you're probably trying to
make the user a member of the group "Administrators" and not
"Administrator"  ResKit has a utility "cusrmgr" that'll make it easier
to play around while you figure out exactly what groups you want to
join.

OT, but if you're using a domain, you probably want to add the user to
the domain and make it a "Domain Admin" on the DC or add it to local
"Administrators" accounts on various computers, not an Administrator
on the DC.



More information about the Python-list mailing list