Lines 1467-1481
class ldapDnOrNone(simple):
|
Link Here
|
---|
|
1467 |
return text |
1467 |
return text |
1468 |
raise univention.admin.uexceptions.valueError,_("Not a valid LDAP DN") |
1468 |
raise univention.admin.uexceptions.valueError,_("Not a valid LDAP DN") |
1469 |
|
1469 |
|
1470 |
class ldapObjectClass(simple): |
|
|
1471 |
@classmethod |
1472 |
def parse(self, text): |
1473 |
return text |
1474 |
|
1470 |
|
1475 |
class ldapAttribute(simple): |
1471 |
class ldapObjectClass(select): |
1476 |
@classmethod |
1472 |
choices = (('top', 'top')) |
1477 |
def parse(self, text): |
1473 |
|
1478 |
return text |
1474 |
|
|
|
1475 |
class ldapAttribute(select): |
1476 |
choices = () |
1477 |
|
1478 |
|
1479 |
def _update_schema(): |
1480 |
from univention.uldap import getMachineConnection |
1481 |
from ldap.schema import (SubSchema, ObjectClass, AttributeType) |
1482 |
conn = getMachineConnection() |
1483 |
try: |
1484 |
results = conn.lo.search_ext_s( |
1485 |
base='cn=Subschema', |
1486 |
scope=ldap.SCOPE_BASE, |
1487 |
attrlist=['attributeTypes', 'objectClasses']) |
1488 |
result, = results |
1489 |
dn, entry = result |
1490 |
subschema = SubSchema(entry) |
1491 |
|
1492 |
sorter = lambda s: s.lower() |
1493 |
ocs = set() |
1494 |
for oid in subschema.listall(ObjectClass): |
1495 |
oc = subschema.get_obj(ObjectClass, oid) |
1496 |
ocs |= set(oc.names) |
1497 |
ldapObjectClass.choices = [(oc, oc) for oc in sorted(ocs, key=sorter)] |
1498 |
attrs = set() |
1499 |
for oid in subschema.listall(AttributeType): |
1500 |
attr = subschema.get_obj(AttributeType, oid) |
1501 |
attrs |= set(attr.names) |
1502 |
ldapAttribute.choices = [(attr, attr) for attr in sorted(attrs, key=sorter)] |
1503 |
except ldap.SERVER_DOWN: |
1504 |
pass |
1505 |
finally: |
1506 |
conn.lo.unbind() |
1507 |
__register_choice_update_function(_update_schema) |
1508 |
|
1479 |
|
1509 |
|
1480 |
class ldapFilter(simple): |
1510 |
class ldapFilter(simple): |
1481 |
|
1511 |
|
Lines 2522-2528
class MinuteSimple(select):
|
Link Here
|
---|
|
2522 |
class UNIX_AccessRight( simple ): |
2552 |
class UNIX_AccessRight( simple ): |
2523 |
pass |
2553 |
pass |
2524 |
|
2554 |
|
2525 |
# Widget supports setgid/sticky bit |
2555 |
# Widget supports setgid/sticky bit |
2526 |
class UNIX_AccessRight_extended( simple ): |
2556 |
class UNIX_AccessRight_extended( simple ): |
2527 |
pass |
2557 |
pass |
2528 |
|
2558 |
|
Lines 2612-2629
class univentionAdminModules(select):
|
Link Here
|
---|
|
2612 |
return text |
2642 |
return text |
2613 |
raise univention.admin.uexceptions.valueInvalidSyntax, _('"%s" is not a Univention Admin Module.') % text |
2643 |
raise univention.admin.uexceptions.valueInvalidSyntax, _('"%s" is not a Univention Admin Module.') % text |
2614 |
|
2644 |
|
2615 |
# Unfortunately, Python doesn't seem to support (static) class methods; |
2645 |
@classmethod |
2616 |
# however, (static) class variables such as "choices" seem to work; |
2646 |
def _update_choices(cls): |
2617 |
# so, we'll modify "choices" using this global method |
2647 |
cls.choices = sorted([ |
2618 |
def univentionAdminModules_update(): |
2648 |
(name, univention.admin.modules.short_description(mod)) |
2619 |
temp = [] |
2649 |
for name, mod in univention.admin.modules.modules.items() |
2620 |
for name, mod in univention.admin.modules.modules.items(): |
2650 |
if not univention.admin.modules.virtual(mod) |
2621 |
if not univention.admin.modules.virtual( mod ): |
2651 |
] , key=operator.itemgetter(1)) |
2622 |
temp.append( ( name, univention.admin.modules.short_description( mod ) ) ) |
|
|
2623 |
|
2624 |
univentionAdminModules.choices = sorted( temp, key = operator.itemgetter( 1 ) ) |
2625 |
|
2652 |
|
2626 |
__register_choice_update_function(univentionAdminModules_update) |
2653 |
__register_choice_update_function(univentionAdminModules._update_choices) |
2627 |
|
2654 |
|
2628 |
class UDM_PropertySelect( complex ): |
2655 |
class UDM_PropertySelect( complex ): |
2629 |
subsyntaxes = ( ( _( 'UDM module' ), string ), ( _( 'property' ), string ) ) |
2656 |
subsyntaxes = ( ( _( 'UDM module' ), string ), ( _( 'property' ), string ) ) |
Lines 2707-2717
class LDAP_Search( select ):
|
Link Here
|
---|
|
2707 |
Searches can be either defined dynamically via a UDM settings/syntax |
2734 |
Searches can be either defined dynamically via a UDM settings/syntax |
2708 |
definition and using |
2735 |
definition and using |
2709 |
|
2736 |
|
2710 |
>>> LDAP_Search( syntax_name = '<NAME>' ) |
2737 |
> LDAP_Search( syntax_name = '<NAME>' ) |
2711 |
|
2738 |
|
2712 |
or programmatically by directly instantiating |
2739 |
or programmatically by directly instantiating |
2713 |
|
2740 |
|
2714 |
>>> LDAP_Search( filter = '<LDAP-Search-Filter>', attribute = [ '<LDAP attributes>', ... ], value = '<LDAP attribute>', base = '<LDAP base>' ) |
2741 |
> LDAP_Search( filter = '<LDAP-Search-Filter>', attribute = [ '<LDAP attributes>', ... ], value = '<LDAP attribute>', base = '<LDAP base>' ) |
2715 |
""" |
2742 |
""" |
2716 |
FILTER_PATTERN = '(&(objectClass=univentionSyntax)(cn=%s))' |
2743 |
FILTER_PATTERN = '(&(objectClass=univentionSyntax)(cn=%s))' |
2717 |
|
2744 |
|