Advertisement
Guest User

Untitled

a guest
Mar 9th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. import sys
  2. import os
  3. import uuid
  4. import kopano
  5. import mysql.connector
  6.  
  7. USER="root"
  8. PASSWORD=""
  9. HOST="localhost"
  10. DB="kopano"
  11.  
  12. cnx = mysql.connector.connect(user=USER, password=PASSWORD,
  13. host=HOST,
  14. database=DB)
  15.  
  16. cursor = cnx.cursor()
  17. cursor.execute("select user_name from stores WHERE user_name LIKE '%@%';")
  18.  
  19. users = cursor.fetchall()
  20.  
  21. for x in users:
  22. print "Fixing:",x[0]
  23. storeguid=kopano.Server().user(x[0]).store
  24. hierarchyid=kopano.Server().user(x[0]).folder("Gesendete Objekte")
  25.  
  26. query = ("SELECT id FROM hierarchy WHERE parent=%d AND type=5" % hierarchyid.hierarchyid)
  27.  
  28. cursor = cnx.cursor()
  29. cursor.execute(query)
  30.  
  31. result = []
  32. for (id,) in cursor:
  33. result.append(id)
  34.  
  35. for id in result:
  36. newentryid = '00000000' + storeguid.guid + '0100000005000000' + uuid.uuid4().hex.upper() + '00000000'
  37. query = ("UPDATE indexedproperties SET val_binary = UNHEX('%s') WHERE tag = 4095 AND hierarchyid = %d" % (newentryid, id))
  38. cursor.execute(query)
  39.  
  40. cnx.commit()
  41.  
  42. cnx.close()
  43. os.system("/usr/sbin/kopano-srvadm --clear-cache all")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement