def LocalGroup(uname=None):
 level = 3
 if (uname is None):
  uname = win32api.GetUserName()
 if (uname.find('\\') < 0):
  uname = ((win32api.GetDomainName() + '\\') + uname)
 group = 'python_test_group'
 try:
  win32net.NetLocalGroupDel(server, group)
  print "WARNING: existing local group '%s' has been deleted."
 except win32net.error:
  pass
 group_data = {'name': group}
 win32net.NetLocalGroupAdd(server, 1, group_data)
 try:
  u = {'domainandname': uname}
  win32net.NetLocalGroupAddMembers(server, group, level, [u])
  (mem, tot, res) = win32net.NetLocalGroupGetMembers(server, group, level)
  print 'members are', mem
  if (mem[0]['domainandname'] != uname):
   print ('ERROR: LocalGroup just added %s, but members are %r' % (uname, mem))
  win32net.NetLocalGroupDelMembers(server, group, [m['domainandname'] for m in mem])
 finally:
  win32net.NetLocalGroupDel(server, group)
 print 'Created a local group, added and removed members, then deleted the group'

def LocalGroup ( uname = None ) : level = 3 if ( uname is None ) : uname = win32api . GetUserName ( ) if ( uname . find ( '\\' ) < 0 ) : uname = ( ( win32api . GetDomainName ( ) + '\\' ) + uname ) group = 'python_test_group' try : win32net . NetLocalGroupDel ( server , group ) print "WARNING: existing local group '%s' has been deleted." except win32net . error : pass group_data = { 'name' : group } win32net . NetLocalGroupAdd ( server , 1 , group_data ) try : u = { 'domainandname' : uname } win32net . NetLocalGroupAddMembers ( server , group , level , [ u ] ) ( mem , tot , res ) = win32net . NetLocalGroupGetMembers ( server , group , level ) print 'members are' , mem if ( mem [ 0 ] [ 'domainandname' ] != uname ) : print ( 'ERROR: LocalGroup just added %s, but members are %r' % ( uname , mem ) ) win32net . NetLocalGroupDelMembers ( server , group , [ m [ 'domainandname' ] for m in mem ] ) finally : win32net . NetLocalGroupDel ( server , group ) print 'Created a local group, added and removed members, then deleted the group'
creates a local group .