cubicweb/misc/scripts/ldap_change_base_dn.py
changeset 11774 51c160677afe
parent 11057 0b59724cb3f2
child 12146 d540defa0591
equal deleted inserted replaced
11773:054a947b5415 11774:51c160677afe
    12 
    12 
    13 assert olddn != newdn
    13 assert olddn != newdn
    14 
    14 
    15 raw_input("Ensure you've stopped the instance, type enter when done.")
    15 raw_input("Ensure you've stopped the instance, type enter when done.")
    16 
    16 
    17 for eid, extid in sql("SELECT eid, extid FROM entities WHERE source='%s'" % uri):
    17 for eid, olduserdn in rql("Any X, XURI WHERE X cwuri XURI, X cw_source S, S name %(name)s",
    18     olduserdn = b64decode(extid)
    18                           {'name': uri}):
    19     newuserdn = olduserdn.replace(olddn, newdn)
    19     newuserdn = olduserdn.replace(olddn, newdn)
    20     if newuserdn != olduserdn:
    20     if newuserdn != olduserdn:
    21         print(olduserdn, '->', newuserdn)
    21         print(olduserdn, '->', newuserdn)
    22         sql("UPDATE entities SET extid='%s' WHERE eid=%s" % (b64encode(newuserdn), eid))
    22         sql("UPDATE cw_cwuser SET cw_cwuri='%s' WHERE cw_eid=%s" % (newuserdn, eid))
    23 
    23 
    24 commit()
    24 commit()
    25 
    25 
    26 print('you can now update the sources file to the new dn and restart the instance')
    26 print('you can now update the sources file to the new dn and restart the instance')