misc/scripts/ldapuser2ldapfeed.py
branchstable
changeset 8521 dfdffebce8a4
parent 8468 f52bb4226020
child 8535 268b6349baf3
child 8635 c261d9465e65
equal deleted inserted replaced
8520:fcd048fa6e6d 8521:dfdffebce8a4
     2 
     2 
     3 Once this script is run, execute c-c db-check to cleanup relation tables.
     3 Once this script is run, execute c-c db-check to cleanup relation tables.
     4 """
     4 """
     5 import sys
     5 import sys
     6 from collections import defaultdict
     6 from collections import defaultdict
       
     7 from logilab.common.shellutils import generate_password
     7 
     8 
     8 try:
     9 try:
     9     source_name, = __args__
    10     source_name, = __args__
    10     source = repo.sources_by_uri[source_name]
    11     source = repo.sources_by_uri[source_name]
    11 except ValueError:
    12 except ValueError:
    55     if not entity.creation_date:
    56     if not entity.creation_date:
    56         entity.cw_edited['creation_date'] = datetime.now()
    57         entity.cw_edited['creation_date'] = datetime.now()
    57     if not entity.modification_date:
    58     if not entity.modification_date:
    58         entity.cw_edited['modification_date'] = datetime.now()
    59         entity.cw_edited['modification_date'] = datetime.now()
    59     if not entity.upassword:
    60     if not entity.upassword:
    60         entity.cw_edited['upassword'] = u''
    61         entity.cw_edited['upassword'] = generate_password()
    61     extid = entity.cw_metainformation()['extid']
    62     extid = entity.cw_metainformation()['extid']
    62     if not entity.cwuri:
    63     if not entity.cwuri:
    63         entity.cw_edited['cwuri'] = '%s/?dn=%s' % (
    64         entity.cw_edited['cwuri'] = '%s/?dn=%s' % (
    64             source.urls[0], extid.decode('utf-8', 'ignore'))
    65             source.urls[0], extid.decode('utf-8', 'ignore'))
    65     print entity.cw_edited
    66     print entity.cw_edited