|
14 | 14 |
|
15 | 15 | SPAWNER_SUBMIT_DATA = '1' |
16 | 16 | LDAP_SEARCH_ATTRIBUTE_QUERY = '2' |
| 17 | +SPAWNER_USER_STATE = '3' |
17 | 18 | DYNAMIC_ATTRIBUTE_METHODS = (SPAWNER_SUBMIT_DATA, |
18 | | - LDAP_SEARCH_ATTRIBUTE_QUERY) |
| 19 | + LDAP_SEARCH_ATTRIBUTE_QUERY, |
| 20 | + SPAWNER_USER_STATE) |
19 | 21 |
|
20 | 22 | INCREMENT_ATTRIBUTE = '1' |
21 | 23 | SEARCH_RESULT_OPERATION_ACTIONS = (INCREMENT_ATTRIBUTE,) |
@@ -351,15 +353,18 @@ def get_interpolated_dynamic_attributes(logger, sources, dynamic_attributes): |
351 | 353 | if attr_val == LDAP_SEARCH_ATTRIBUTE_QUERY: |
352 | 354 | if LDAP_SEARCH_ATTRIBUTE_QUERY in sources \ |
353 | 355 | and sources[LDAP_SEARCH_ATTRIBUTE_QUERY]: |
354 | | - attribute = get_dict_key(sources[LDAP_SEARCH_ATTRIBUTE_QUERY], |
355 | | - attr_key) |
356 | | - val = attribute |
| 356 | + val = get_dict_key(sources[LDAP_SEARCH_ATTRIBUTE_QUERY], |
| 357 | + attr_key) |
357 | 358 | if attr_val == SPAWNER_SUBMIT_DATA: |
358 | 359 | if SPAWNER_SUBMIT_DATA in sources \ |
359 | 360 | and sources[SPAWNER_SUBMIT_DATA]: |
360 | | - attribute = get_dict_key(sources[SPAWNER_SUBMIT_DATA], |
361 | | - attr_key) |
362 | | - val = attribute |
| 361 | + val = get_dict_key(sources[SPAWNER_SUBMIT_DATA], |
| 362 | + attr_key) |
| 363 | + if attr_val == SPAWNER_USER_STATE: |
| 364 | + if SPAWNER_USER_STATE in sources \ |
| 365 | + and sources[SPAWNER_USER_STATE]: |
| 366 | + val = get_dict_key(sources[SPAWNER_USER_STATE], |
| 367 | + attr_key) |
363 | 368 | if not val: |
364 | 369 | logger.error("LDAP - Missing {} in {} which is required for {} in" |
365 | 370 | " get_interpolated_dynamic_attributes".format( |
@@ -572,7 +577,8 @@ def setup_ldap_entry_hook(spawner): |
572 | 577 | "LDAP - Retrived attributes {}".format(attributes)) |
573 | 578 | # Extract attributes from existing object |
574 | 579 | sources = {LDAP_SEARCH_ATTRIBUTE_QUERY: attributes, |
575 | | - SPAWNER_SUBMIT_DATA: ldap_dict} |
| 580 | + SPAWNER_SUBMIT_DATA: ldap_dict, |
| 581 | + SPAWNER_USER_STATE: spawner.user} |
576 | 582 | spawner.log.debug("LDAP - dynamic_attributes " |
577 | 583 | "pre interpolated: {}".format( |
578 | 584 | instance.dynamic_attributes |
@@ -652,7 +658,8 @@ def setup_ldap_entry_hook(spawner): |
652 | 658 | ldap_dict.update(attributes) |
653 | 659 |
|
654 | 660 | # Prepare required dynamic attributes |
655 | | - sources.update({SPAWNER_SUBMIT_DATA: ldap_dict}) |
| 661 | + sources.update({SPAWNER_SUBMIT_DATA: ldap_dict, |
| 662 | + SPAWNER_USER_STATE: spawner.user}) |
656 | 663 | spawner.log.debug("LDAP - Sources state before interpolating with " |
657 | 664 | " dynamic attributes {}".format(sources)) |
658 | 665 | prepared_dynamic_attributes = get_interpolated_dynamic_attributes( |
|
0 commit comments