admin scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
756 B

  1. #!/usr/bin/python3
  2. """
  3. Fixing shit I fucked.
  4. Running on the output of this search
  5. ldapsearch -D cn=root,ou=ldap,o=redbrick -y /etc/ldap.secret -xLLL "(|(objectClass=club)
  6. (objectClass=society)(objectClass=projects)(objectClass=redbrick)(objectClass=dcu)
  7. """
  8. import sys
  9. def modify_template(user_id):
  10. """print modify ldif template"""
  11. ldap_dn = 'dn: uid=' + user_id.strip()
  12. ldap_dn += "\nchangetype: modify\ndelete: yearsPaid\n\n"
  13. print(ldap_dn)
  14. # open ldif
  15. with open(sys.argv[1], 'r') as content:
  16. LDIF = content.read()
  17. # split by user
  18. GETDN = LDIF.split('dn: uid=')
  19. for i in GETDN:
  20. try:
  21. thisdn = i.split('\n')
  22. uid = thisdn[0]
  23. if uid:
  24. modify_template(uid)
  25. except IndexError:
  26. continue