def DeleteUser(username, token=None):
 token = data_store.GetDefaultToken(token)
 user_urn = ('aff4:/users/%s' % username)
 try:
  aff4.FACTORY.Open(user_urn, users.GRRUser, token=token)
 except aff4.InstantiationError:
  EPrint(('User %s not found.' % username))
  return
 aff4.FACTORY.Delete(user_urn, token=token)
 EPrint(('User %s has been deleted.' % username))
 events.Events.PublishEvent('Audit', events.AuditEvent(user=token.username, action='USER_DELETE', urn=user_urn), token=token)

def DeleteUser ( username , token = None ) : token = data_store . GetDefaultToken ( token ) user_urn = ( 'aff4:/users/%s' % username ) try : aff4 . FACTORY . Open ( user_urn , users . GRRUser , token = token ) except aff4 . InstantiationError : EPrint ( ( 'User %s not found.' % username ) ) return aff4 . FACTORY . Delete ( user_urn , token = token ) EPrint ( ( 'User %s has been deleted.' % username ) ) events . Events . PublishEvent ( 'Audit' , events . AuditEvent ( user = token . username , action = 'USER_DELETE' , urn = user_urn ) , token = token )
deletes an existing user .