Lines 377-383
def __getitem__(self, key):
|
Link Here
|
---|
|
377 |
def get_default_values(self, property_name): |
377 |
def get_default_values(self, property_name): |
378 |
"""Depending on the syntax of the given property a default |
378 |
"""Depending on the syntax of the given property a default |
379 |
search pattern/value is returned""" |
379 |
search pattern/value is returned""" |
380 |
MODULE.info('Searching for property %s' % property_name) |
380 |
MODULE.info('Searching for property %r' % property_name) |
381 |
for key, prop in getattr(self.module, 'property_descriptions', {}).items(): |
381 |
for key, prop in getattr(self.module, 'property_descriptions', {}).items(): |
382 |
if key == property_name: |
382 |
if key == property_name: |
383 |
value = default_value(prop.syntax) |
383 |
value = default_value(prop.syntax) |
|
399 |
password_properties = self.password_properties |
399 |
password_properties = self.password_properties |
400 |
for property_name, value in sorted(properties.items(), _tmp_cmp): |
400 |
for property_name, value in sorted(properties.items(), _tmp_cmp): |
401 |
if property_name in password_properties: |
401 |
if property_name in password_properties: |
402 |
MODULE.info('Setting password property %s' % (property_name,)) |
402 |
MODULE.info('Setting password property %r' % (property_name,)) |
403 |
else: |
403 |
else: |
404 |
MODULE.info('Setting property %s to %s' % (property_name, value)) |
404 |
MODULE.info('Setting property %r to %r' % (property_name, value)) |
405 |
|
405 |
|
406 |
property_obj = self.get_property(property_name) |
406 |
property_obj = self.get_property(property_name) |
407 |
if property_obj is None: |
407 |
if property_obj is None: |
408 |
raise UMC_OptionMissing(_('Property %s not found') % property_name) |
408 |
raise UMC_OptionMissing(_('Property %r not found') % property_name) |
409 |
|
409 |
|
410 |
# check each element if 'value' is a list |
410 |
# check each element if 'value' is a list |
411 |
if isinstance(value, (tuple, list)) and property_obj.multivalue: |
411 |
if isinstance(value, (tuple, list)) and property_obj.multivalue: |
Lines 466-472
def create(self, ldap_object, container=None, superordinate=None, ldap_connectio
|
Link Here
|
---|
|
466 |
MODULE.info('Found UDM module for superordinate') |
466 |
MODULE.info('Found UDM module for superordinate') |
467 |
superordinate = mod.get(superordinate) |
467 |
superordinate = mod.get(superordinate) |
468 |
else: |
468 |
else: |
469 |
MODULE.error('Superordinate module not found: %s' % (superordinate,)) |
469 |
MODULE.error('Superordinate module not found: %r' % (superordinate,)) |
470 |
raise SuperordinateDoesNotExist(superordinate) |
470 |
raise SuperordinateDoesNotExist(superordinate) |
471 |
else: |
471 |
else: |
472 |
superordinate = udm_objects.get_superordinate(self.module, None, ldap_connection, container) |
472 |
superordinate = udm_objects.get_superordinate(self.module, None, ldap_connection, container) |
Lines 501-507
def move(self, ldap_dn, container, ldap_connection=None, ldap_position=None):
|
Link Here
|
---|
|
501 |
# build new dn |
501 |
# build new dn |
502 |
rdn = udm.uldap.explodeDn(ldap_dn)[0] |
502 |
rdn = udm.uldap.explodeDn(ldap_dn)[0] |
503 |
dest = '%s,%s' % (rdn, container) |
503 |
dest = '%s,%s' % (rdn, container) |
504 |
MODULE.info('Moving LDAP object %s to %s' % (ldap_dn, dest)) |
504 |
MODULE.info('Moving LDAP object %r to %r' % (ldap_dn, dest)) |
505 |
obj.move(dest) |
505 |
obj.move(dest) |
506 |
return dest |
506 |
return dest |
507 |
except udm_errors.base as e: |
507 |
except udm_errors.base as e: |
Lines 515-521
def remove(self, ldap_dn, cleanup=False, recursive=False, ldap_connection=None,
|
Link Here
|
---|
|
515 |
obj = self.module.object(None, ldap_connection, ldap_position, dn=ldap_dn, superordinate=superordinate) |
515 |
obj = self.module.object(None, ldap_connection, ldap_position, dn=ldap_dn, superordinate=superordinate) |
516 |
try: |
516 |
try: |
517 |
obj.open() |
517 |
obj.open() |
518 |
MODULE.info('Removing LDAP object %s' % ldap_dn) |
518 |
MODULE.info('Removing LDAP object %r' % ldap_dn) |
519 |
obj.remove(remove_childs=recursive) |
519 |
obj.remove(remove_childs=recursive) |
520 |
if cleanup: |
520 |
if cleanup: |
521 |
udm_objects.performCleanup(obj) |
521 |
udm_objects.performCleanup(obj) |
Lines 527-533
def remove(self, ldap_dn, cleanup=False, recursive=False, ldap_connection=None,
|
Link Here
|
---|
|
527 |
def modify(self, ldap_object, ldap_connection=None, ldap_position=None): |
527 |
def modify(self, ldap_object, ldap_connection=None, ldap_position=None): |
528 |
"""Modifies a LDAP object""" |
528 |
"""Modifies a LDAP object""" |
529 |
superordinate = udm_objects.get_superordinate(self.module, None, ldap_connection, ldap_object['$dn$']) |
529 |
superordinate = udm_objects.get_superordinate(self.module, None, ldap_connection, ldap_object['$dn$']) |
530 |
MODULE.info('Modifying object %s with superordinate %s' % (ldap_object['$dn$'], superordinate)) |
530 |
MODULE.info('Modifying object %r with superordinate %r' % (ldap_object['$dn$'], superordinate)) |
531 |
obj = self.module.object(None, ldap_connection, ldap_position, dn=ldap_object.get('$dn$'), superordinate=superordinate) |
531 |
obj = self.module.object(None, ldap_connection, ldap_position, dn=ldap_object.get('$dn$'), superordinate=superordinate) |
532 |
del ldap_object['$dn$'] |
532 |
del ldap_object['$dn$'] |
533 |
|
533 |
|
Lines 535-541
def modify(self, ldap_object, ldap_connection=None, ldap_position=None):
|
Link Here
|
---|
|
535 |
obj.open() |
535 |
obj.open() |
536 |
if '$options$' in ldap_object: |
536 |
if '$options$' in ldap_object: |
537 |
obj.options = filter(lambda option: ldap_object['$options$'][option] == True, ldap_object['$options$'].keys()) |
537 |
obj.options = filter(lambda option: ldap_object['$options$'][option] == True, ldap_object['$options$'].keys()) |
538 |
MODULE.info('Setting new options to %s' % str(obj.options)) |
538 |
MODULE.info('Setting new options to %r' % str(obj.options)) |
539 |
del ldap_object['$options$'] |
539 |
del ldap_object['$options$'] |
540 |
MODULE.info('Modifying LDAP object %s' % obj.dn) |
540 |
MODULE.info('Modifying LDAP object %s' % obj.dn) |
541 |
if '$policies$' in ldap_object: |
541 |
if '$policies$' in ldap_object: |
Lines 560-566
def search(self, container=None, attribute=None, value=None, superordinate=None,
|
Link Here
|
---|
|
560 |
if attribute in [None, 'None'] and filter: |
560 |
if attribute in [None, 'None'] and filter: |
561 |
filter_s = str(filter) |
561 |
filter_s = str(filter) |
562 |
|
562 |
|
563 |
MODULE.info('Searching for LDAP objects: container = %s, filter = %s, superordinate = %s' % (container, filter_s, superordinate)) |
563 |
MODULE.info('Searching for LDAP objects: container = %r, filter = %r, superordinate = %r' % (container, filter_s, superordinate)) |
564 |
result = None |
564 |
result = None |
565 |
try: |
565 |
try: |
566 |
sizelimit = int(ucr.get('directory/manager/web/sizelimit', '2000')) |
566 |
sizelimit = int(ucr.get('directory/manager/web/sizelimit', '2000')) |
Lines 1164-1170
def get_module(flavor, ldap_dn, ldap_connection=None, ldap_position=None):
|
Link Here
|
---|
|
1164 |
|
1164 |
|
1165 |
module = UDM_Module(modules[0]) |
1165 |
module = UDM_Module(modules[0]) |
1166 |
if module.module is None: |
1166 |
if module.module is None: |
1167 |
MODULE.error('Identified module %s for %s (flavor=%s) does not have a relating UDM module.' % (modules[0], ldap_dn, flavor)) |
1167 |
MODULE.error('Identified module %r for %r (flavor=%r) does not have a relating UDM module.' % (modules[0], ldap_dn, flavor)) |
1168 |
return None |
1168 |
return None |
1169 |
return module |
1169 |
return module |
1170 |
|
1170 |
|
Lines 1286-1292
def search_syntax_choices_by_key(syntax_name, key):
|
Link Here
|
---|
|
1286 |
options = {'objectProperty': attr, 'objectPropertyValue': key} |
1286 |
options = {'objectProperty': attr, 'objectPropertyValue': key} |
1287 |
return read_syntax_choices(syntax_name, options) |
1287 |
return read_syntax_choices(syntax_name, options) |
1288 |
|
1288 |
|
1289 |
MODULE.warn('Syntax "%s": No fast search function' % syntax_name) |
1289 |
MODULE.warn('Syntax %r: No fast search function' % syntax_name) |
1290 |
# return them all, as there is no reason to filter after everything has loaded |
1290 |
# return them all, as there is no reason to filter after everything has loaded |
1291 |
# frontend will cache it. |
1291 |
# frontend will cache it. |
1292 |
return read_syntax_choices(syntax_name) |
1292 |
return read_syntax_choices(syntax_name) |
Lines 1341-1347
def read_syntax_choices(syntax_name, options={}, module_search_options={}, ldap_
|
Link Here
|
---|
|
1341 |
else: |
1341 |
else: |
1342 |
simple = True |
1342 |
simple = True |
1343 |
if not simple: |
1343 |
if not simple: |
1344 |
MODULE.warn('Syntax %s wants to get optimizations but may not. This is a Bug! We provide a fallback but the syntax will respond much slower than it could!' % syntax_name) |
1344 |
MODULE.warn('Syntax %r wants to get optimizations but may not. This is a Bug! We provide a fallback but the syntax will respond much slower than it could!' % syntax_name) |
1345 |
|
1345 |
|
1346 |
def extract_key_label(syn, dn, info): |
1346 |
def extract_key_label(syn, dn, info): |
1347 |
key = label = None |
1347 |
key = label = None |
Lines 1462-1468
def map_choice(obj):
|
Link Here
|
---|
|
1462 |
module = UDM_Module(syn.udm_module) |
1462 |
module = UDM_Module(syn.udm_module) |
1463 |
if module.module is None: |
1463 |
if module.module is None: |
1464 |
return |
1464 |
return |
1465 |
MODULE.info('Found syntax %s with udm_module property' % syntax_name) |
1465 |
MODULE.info('Found syntax %r with udm_module property' % (syntax_name,)) |
1466 |
if syn.udm_filter == 'dn': |
1466 |
if syn.udm_filter == 'dn': |
1467 |
syn.choices = map_choice(module.get(options[syn.depends])) |
1467 |
syn.choices = map_choice(module.get(options[syn.depends])) |
1468 |
else: |
1468 |
else: |
Lines 1482-1488
def map_choice(obj):
|
Link Here
|
---|
|
1482 |
try: |
1482 |
try: |
1483 |
result = ldap_connection.searchDn(filter=syn.searchFilter) |
1483 |
result = ldap_connection.searchDn(filter=syn.searchFilter) |
1484 |
except udm_errors.base: |
1484 |
except udm_errors.base: |
1485 |
MODULE.process('Failed to initialize syntax class %s' % syntax_name) |
1485 |
MODULE.process('Failed to initialize syntax class %r' % (syntax_name,)) |
1486 |
return |
1486 |
return |
1487 |
syn.choices = [] |
1487 |
syn.choices = [] |
1488 |
for dn in result: |
1488 |
for dn in result: |
Lines 1531-1537
def map_choice(obj):
|
Link Here
|
---|
|
1531 |
id = obj.oldattr[store][0] |
1531 |
id = obj.oldattr[store][0] |
1532 |
else: |
1532 |
else: |
1533 |
# no valid store object, ignore |
1533 |
# no valid store object, ignore |
1534 |
MODULE.warn('LDAP_Search syntax "%s": "%s" is no valid property for object "%s" - ignoring entry.' % (options['syntax'], store, dn)) |
1534 |
MODULE.warn('LDAP_Search syntax %r: %r is no valid property for object %r - ignoring entry.' % (options['syntax'], store, dn)) |
1535 |
continue |
1535 |
continue |
1536 |
|
1536 |
|
1537 |
# find the value to display |
1537 |
# find the value to display |