def CreateUser():
 testName = 'PyNetTestUser'
 try:
  win32net.NetUserDel(server, testName)
  print 'Warning - deleted user before creating it!'
 except win32net.error:
  pass
 d = {}
 d['name'] = testName
 d['password'] = 'deleteme'
 d['priv'] = win32netcon.USER_PRIV_USER
 d['comment'] = 'Delete me - created by Python test code'
 d['flags'] = (win32netcon.UF_NORMAL_ACCOUNT | win32netcon.UF_SCRIPT)
 win32net.NetUserAdd(server, 1, d)
 try:
  try:
   win32net.NetUserChangePassword(server, testName, 'wrong', 'new')
   print 'ERROR: NetUserChangePassword worked with a wrong password!'
  except win32net.error:
   pass
  win32net.NetUserChangePassword(server, testName, 'deleteme', 'new')
 finally:
  win32net.NetUserDel(server, testName)
 print 'Created a user, changed their password, and deleted them!'

def CreateUser ( ) : testName = 'PyNetTestUser' try : win32net . NetUserDel ( server , testName ) print 'Warning - deleted user before creating it!' except win32net . error : pass d = { } d [ 'name' ] = testName d [ 'password' ] = 'deleteme' d [ 'priv' ] = win32netcon . USER_PRIV_USER d [ 'comment' ] = 'Delete me - created by Python test code' d [ 'flags' ] = ( win32netcon . UF_NORMAL_ACCOUNT | win32netcon . UF_SCRIPT ) win32net . NetUserAdd ( server , 1 , d ) try : try : win32net . NetUserChangePassword ( server , testName , 'wrong' , 'new' ) print 'ERROR: NetUserChangePassword worked with a wrong password!' except win32net . error : pass win32net . NetUserChangePassword ( server , testName , 'deleteme' , 'new' ) finally : win32net . NetUserDel ( server , testName ) print 'Created a user, changed their password, and deleted them!'
creates a new test user .