Changeset 1271
- Timestamp:
- Mar 28, 2023, 4:18:16 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dassldapsync/dassldapsync.py
r1262 r1271 34 34 parser = argparse.ArgumentParser(description='Synchronize the content of two LDAP servers.') 35 35 parser.add_argument('-d', '--debug', action='store_true', help="enable debug output") 36 parser.add_argument('-n', '--dry-run', action='store_true', dest='dryrun', help="dry run") 36 37 parser.add_argument('configfile', default=configfile, 37 38 help="Configuration file [default: {}]".format(configfile)) … … 41 42 class Options(object): 42 43 def __init__(self): 43 self.delete = True 44 self.create = False 45 self.delete = False 44 46 self.starttls = False 45 47 self.updateonly = False … … 198 200 existingDestDn, existingDestEntry = searchresult[0] 199 201 if existingDestDn.lower() != dn.lower(): 200 self.con.modrdn_s(existingDestDn, dn) 202 if not self.options.dryrun: 203 self.con.modrdn_s(existingDestDn, dn) 201 204 self.notify_renamed(existingDestDn, dn, 202 205 existingDestEntry[self.options.renameattr][0], … … 262 265 try: 263 266 self.logger.debug('mod_attrs: ' + str(mod_attrs)) 264 self.con.modify_s(srcDn, mod_attrs) 267 if not self.options.dryrun: 268 self.con.modify_s(srcDn, mod_attrs) 265 269 self.notify_modified(srcDn) 266 270 except: … … 271 275 272 276 except ldap.NO_SUCH_OBJECT: 273 if not self.options.updateonly:277 if self.options.create: 274 278 try: 275 279 entry = ldap.modlist.addModlist(srcAttributes, self.junk_attrs) 276 self.con.add_s(srcDn, entry) 280 if not self.options.dryrun: 281 self.con.add_s(srcDn, entry) 277 282 self.notify_created(srcDn) 278 283 except (ldap.OBJECT_CLASS_VIOLATION, … … 312 317 if self.__is_dn_included(dn): 313 318 try: 314 self.con.delete_s(dn) 319 if not self.options.dryrun: 320 self.con.delete_s(dn) 315 321 self.notify_deleted(dn) 316 322 except: … … 330 336 update_objects = self.__adapt_source_ldap_objects(searchresult) 331 337 self.__syncLdapDestination(update_objects) 332 if self.options.delete and not self.options.updateonly:338 if self.options.delete: 333 339 self.__deleteDestLdapObjects(update_objects) 334 340 self.con.unbind() … … 609 615 pass 610 616 611 options.updateonly = not config.getboolean("destination", "create", fallback=False) 617 options.dryrun = args.dryrun 618 options.create = config.getboolean("destination", "create", fallback=False) 612 619 options.delete = config.getboolean("destination", "delete", fallback=False) 613 620 options.starttls = config.getboolean("destination", "starttls", fallback=False)
Note:
See TracChangeset
for help on using the changeset viewer.