View | Details | Raw Unified | Return to bug 43129 | Differences between
and this patch

Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/settings/extended_attribute.py (+25 lines)
 Lines 378-383    Link Here 
378
		identifies=False,
378
		identifies=False,
379
		copyable=True,
379
		copyable=True,
380
	),
380
	),
381
	'mapMethod': univention.admin.property(
382
		short_description=_('Map method'),
383
		long_description=_('Defines a custom UDM property to LDAP attribute mapping method.'),
384
		syntax=univention.admin.syntax.string,
385
		multivalue=False,
386
		options=[],
387
		required=False,
388
		may_change=True,
389
		identifies=False,
390
		copyable=True,
391
	),
392
	'unmapMethod': univention.admin.property(
393
		short_description=_('Unmap method'),
394
		long_description=_('Defines a custom LDAP attribute to UDM property mapping method.'),
395
		syntax=univention.admin.syntax.string,
396
		multivalue=False,
397
		options=[],
398
		required=False,
399
		may_change=True,
400
		identifies=False,
401
		copyable=True,
402
	),
381
}
403
}
382
404
383
layout = [
405
layout = [
 Lines 425-430    Link Here 
425
	]),
447
	]),
426
	Tab(_('Data type'), _('Data type definition'), layout=[
448
	Tab(_('Data type'), _('Data type definition'), layout=[
427
		["syntax", "default"],
449
		["syntax", "default"],
450
		["mapMethod", "unmapMethod"],
428
		["multivalue"],
451
		["multivalue"],
429
		["valueRequired"],
452
		["valueRequired"],
430
		["mayChange"],
453
		["mayChange"],
 Lines 459-464    Link Here 
459
mapping.register('notEditable', 'univentionUDMPropertyValueNotEditable', None, univention.admin.mapping.ListToString)
482
mapping.register('notEditable', 'univentionUDMPropertyValueNotEditable', None, univention.admin.mapping.ListToString)
460
mapping.register('doNotSearch', 'univentionUDMPropertyDoNotSearch', None, univention.admin.mapping.ListToString)
483
mapping.register('doNotSearch', 'univentionUDMPropertyDoNotSearch', None, univention.admin.mapping.ListToString)
461
mapping.register('copyable', 'univentionUDMPropertyCopyable', None, univention.admin.mapping.ListToString)
484
mapping.register('copyable', 'univentionUDMPropertyCopyable', None, univention.admin.mapping.ListToString)
485
mapping.register('mapMethod', 'univentionUDMPropertyMapMethod', None, univention.admin.mapping.ListToString)
486
mapping.register('unmapMethod', 'univentionUDMPropertyUnMapMethod', None, univention.admin.mapping.ListToString)
462
mapping.register('version', 'univentionUDMPropertyVersion', None, univention.admin.mapping.ListToString)
487
mapping.register('version', 'univentionUDMPropertyVersion', None, univention.admin.mapping.ListToString)
463
mapping.register('CLIName', 'univentionUDMPropertyCLIName', None, univention.admin.mapping.ListToString)
488
mapping.register('CLIName', 'univentionUDMPropertyCLIName', None, univention.admin.mapping.ListToString)
464
mapping.register('options', 'univentionUDMPropertyOptions')
489
mapping.register('options', 'univentionUDMPropertyOptions')
(-)a/management/univention-directory-manager-modules/modules/univention/admin/modules.py (-14 / +17 lines)
 Lines 311-331   def update_extended_attributes(lo, module, position): Link Here 
311
			ud.debug(ud.ADMIN, ud.ERROR, 'modules update_extended_attributes: ERROR: processing univentionUDMPropertyDoNotSearch throwed exception - assuming doNotSearch=0')
311
			ud.debug(ud.ADMIN, ud.ERROR, 'modules update_extended_attributes: ERROR: processing univentionUDMPropertyDoNotSearch throwed exception - assuming doNotSearch=0')
312
			doNotSearch = 0
312
			doNotSearch = 0
313
313
314
		map_method = ''
315
		unmap_method = ''
316
314
		# check if CA is multivalue property
317
		# check if CA is multivalue property
315
		if attrs.get('univentionUDMPropertyMultivalue', [''])[0] == '1':
318
		multivalue = attrs.get('univentionUDMPropertyMultivalue', [''])[0] == '1'
316
			multivalue = 1
319
		if not multivalue:
317
			map_method = None
320
			map_method = 'ListToString'
318
			unmap_method = None
319
		else:
320
			multivalue = 0
321
			map_method = univention.admin.mapping.ListToString
322
			unmap_method = None
323
			if propertySyntaxString == 'boolean':
321
			if propertySyntaxString == 'boolean':
324
				map_method = univention.admin.mapping.BooleanListToString
322
				map_method = 'BooleanListToString'
325
				unmap_method = univention.admin.mapping.BooleanUnMap
323
				unmap_method = 'BooleanUnMap'
326
			# single value ==> use only first value
324
			# single value ==> use only first value
327
			propertyDefault = propertyDefault[0]
325
			propertyDefault = propertyDefault[0]
328
326
327
		# extended attribute for objectClass should not be mapped to any attribute/property
328
		if attrs['univentionUDMPropertyLdapMapping'][0].lower() == 'objectClass'.lower():
329
			map_method = 'nothing'
330
			unmap_method = 'nothing'
331
332
		map_method = getattr(univention.admin.mapping, attrs.get('univentionUDMPropertyMapMethod', [map_method])[0], None)
333
		unmap_method = getattr(univention.admin.mapping, attrs.get('univentionUDMPropertyUnMapMethod', [unmap_method])[0], None)
334
329
		# Show this attribute in UDM/UMC?
335
		# Show this attribute in UDM/UMC?
330
		if attrs.get('univentionUDMPropertyLayoutDisable', [''])[0] == '1':
336
		if attrs.get('univentionUDMPropertyLayoutDisable', [''])[0] == '1':
331
			layoutDisabled = True
337
			layoutDisabled = True
 Lines 363-372   def update_extended_attributes(lo, module, position): Link Here 
363
		)
369
		)
364
370
365
		# add LDAP mapping
371
		# add LDAP mapping
366
		if attrs['univentionUDMPropertyLdapMapping'][0].lower() != 'objectClass'.lower():
372
		module.mapping.register(pname, attrs['univentionUDMPropertyLdapMapping'][0], unmap_method, map_method)
367
			module.mapping.register(pname, attrs['univentionUDMPropertyLdapMapping'][0], unmap_method, map_method)
368
		else:
369
			module.mapping.register(pname, attrs['univentionUDMPropertyLdapMapping'][0], univention.admin.mapping.nothing, univention.admin.mapping.nothing)
370
373
371
		if hasattr(module, 'layout'):
374
		if hasattr(module, 'layout'):
372
			tabname = attrs.get('univentionUDMPropertyTranslationTabName;entry-%s' % lang, attrs.get('univentionUDMPropertyLayoutTabName', [_('Custom')]))[0]
375
			tabname = attrs.get('univentionUDMPropertyTranslationTabName;entry-%s' % lang, attrs.get('univentionUDMPropertyLayoutTabName', [_('Custom')]))[0]
(-)a/management/univention-ldap/schema/custom-attribute.schema (+14 lines)
 Lines 291-296   attributetype ( 1.3.6.1.4.1.10176.200.131 NAME 'univentionUDMPropertyCopyable' Link Here 
291
        SUBSTR caseIgnoreSubstringsMatch
291
        SUBSTR caseIgnoreSubstringsMatch
292
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE)
292
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE)
293
293
294
attributetype ( 1.3.6.1.4.1.10176.200.132 NAME 'univentionUDMPropertyMapMethod'
295
        DESC 'defines the UDM property to LDAP attribute mapping method'
296
        EQUALITY caseIgnoreMatch
297
        SUBSTR caseIgnoreSubstringsMatch
298
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE)
299
300
attributetype ( 1.3.6.1.4.1.10176.200.133 NAME 'univentionUDMPropertyUnMapMethod'
301
        DESC 'defines the LDAP attribute to UDM property mapping method'
302
        EQUALITY caseIgnoreMatch
303
        SUBSTR caseIgnoreSubstringsMatch
304
        SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE)
305
294
306
295
objectclass ( 1.3.6.1.4.1.10176.200.199
307
objectclass ( 1.3.6.1.4.1.10176.200.199
296
    NAME 'univentionUDMProperty'
308
    NAME 'univentionUDMProperty'
 Lines 327-332   objectclass ( 1.3.6.1.4.1.10176.200.199 Link Here 
327
			  univentionUDMPropertyTranslationGroupName $
339
			  univentionUDMPropertyTranslationGroupName $
328
			  univentionUDMPropertyLayoutGroupPosition $
340
			  univentionUDMPropertyLayoutGroupPosition $
329
			  univentionUDMPropertyLayoutDisable $
341
			  univentionUDMPropertyLayoutDisable $
342
			  univentionUDMPropertyMapMethod $
343
			  univentionUDMPropertyUnMapMethod $
330
			  univentionUDMPropertyCopyable
344
			  univentionUDMPropertyCopyable
331
			  )
345
			  )
332
	)
346
	)
333
   Bug #43129: add loading of mapping.d
347
   Bug #43129: add loading of mapping.d
(-)a/management/univention-directory-manager-modules/debian/python-univention-directory-manager.install (+1 lines)
 Lines 15-20   modules/univention/admin/handlers/computers/*.py usr/share/pyshared/univention/a Link Here 
15
modules/univention/admin/handlers/kerberos/*.py usr/share/pyshared/univention/admin/handlers/kerberos/
15
modules/univention/admin/handlers/kerberos/*.py usr/share/pyshared/univention/admin/handlers/kerberos/
16
modules/univention/admin/syntax.d/*.py usr/share/pyshared/univention/admin/syntax.d/
16
modules/univention/admin/syntax.d/*.py usr/share/pyshared/univention/admin/syntax.d/
17
modules/univention/admin/hooks.d/*.py usr/share/pyshared/univention/admin/hooks.d/
17
modules/univention/admin/hooks.d/*.py usr/share/pyshared/univention/admin/hooks.d/
18
modules/univention/admin/mapping.d/*.py usr/share/pyshared/univention/admin/mapping.d/
18
python-lib/*.py usr/share/pyshared/univention/lib
19
python-lib/*.py usr/share/pyshared/univention/lib
19
listener/*.py usr/lib/univention-directory-listener/system/
20
listener/*.py usr/lib/univention-directory-listener/system/
20
18python-univention-directory-manager.inst usr/lib/univention-install/
21
18python-univention-directory-manager.inst usr/lib/univention-install/
(-)a/management/univention-directory-manager-modules/modules/univention/admin/__init__.py (+1 lines)
 Lines 513-518   def __init__(self, id, short_description=None, long_description='', members=[]): Link Here 
513
from univention.admin import modules, objects, syntax, hook, mapping
513
from univention.admin import modules, objects, syntax, hook, mapping
514
syntax.import_syntax_files()
514
syntax.import_syntax_files()
515
hook.import_hook_files()
515
hook.import_hook_files()
516
mapping.import_mapping_files()
516
517
517
if __name__ == '__main__':
518
if __name__ == '__main__':
518
	prop = property('_replace')
519
	prop = property('_replace')
(-)a/management/univention-directory-manager-modules/modules/univention/admin/mapping.py (+21 lines)
 Lines 33-38    Link Here 
33
import univention.debug
33
import univention.debug
34
import types
34
import types
35
import base64
35
import base64
36
import traceback
37
import sys
38
import os
39
40
41
def import_mapping_files():
42
	for dir_ in sys.path:
43
		mapping_py = os.path.join(dir_, 'univention/admin/mapping.py')
44
		mapping_d = os.path.join(dir_, 'univention/admin/mapping.d/')
45
46
		if os.path.exists(mapping_py) and os.path.isdir(mapping_d):
47
			mapping_files = (os.path.join(mapping_d, f) for f in os.listdir(mapping_d) if f.endswith('.py'))
48
49
			for fn in mapping_files:
50
				try:
51
					with open(fn, 'r') as fd:
52
						exec fd in sys.modules[__name__].__dict__
53
					univention.debug.debug(univention.debug.ADMIN, univention.debug.INFO, 'admin.mapping.import_mapping_files: importing "%s"' % fn)
54
				except (EnvironmentError, ImportError):
55
					univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'admin.mapping.import_mapping_files: loading %s failed' % fn)
56
					univention.debug.debug(univention.debug.ADMIN, univention.debug.ERROR, 'admin.mapping.import_mapping_files: TRACEBACK:\n%s' % traceback.format_exc())
36
57
37
58
38
def DaysToSeconds(days):
59
def DaysToSeconds(days):
39
   Bug #43129: register ldap indicies for mapping attributes
60
   Bug #43129: register ldap indicies for mapping attributes
40
   
61
   
41
   This should not be done during an errata update! There we need to add
62
   This should not be done during an errata update! There we need to add
42
   them to the postinst and the joinscript!
63
   them to the postinst and the joinscript!
(-)a/management/univention-ldap/scripts/ldap_setup_index (+2 lines)
 Lines 251-256   UDM_PROP_ATTRS = set(( Link Here 
251
    'univentionUDMPropertyValueMayChange',
251
    'univentionUDMPropertyValueMayChange',
252
    'univentionUDMPropertyValueRequired',
252
    'univentionUDMPropertyValueRequired',
253
    'univentionUDMPropertyVersion',
253
    'univentionUDMPropertyVersion',
254
    'univentionUDMPropertyMapMethod',
255
    'univentionUDMPropertyUnMapMethod',
254
))
256
))
255
257
256
RECOMMENDED_LDAP_INDEX = {
258
RECOMMENDED_LDAP_INDEX = {
257
   Bug #43129: add univentionUDMMapping
259
   Bug #43129: add univentionUDMMapping
(-)a/base/univention-lib/python/ldap_extension.py (+29 lines)
 Lines 819-824   class UniventionUDMHook(UniventionUDMExtension): Link Here 
819
	filesuffix = ".py"
819
	filesuffix = ".py"
820
820
821
821
822
class UniventionUDMMapping(UniventionUDMExtension):
823
	target_container_name = "udm_mapping"
824
	udm_module_name = "settings/udm_mapping"
825
	active_flag_attribute = "univentionUDMMappingActive"
826
	filesuffix = ".py"
827
828
822
def option_validate_existing_filename(option, opt, value):
829
def option_validate_existing_filename(option, opt, value):
823
	if not os.path.exists(value):
830
	if not os.path.exists(value):
824
		raise OptionValueError("%s: file does not exist: %s" % (opt, value))
831
		raise OptionValueError("%s: file does not exist: %s" % (opt, value))
 Lines 927-932   def ucs_registerLDAPExtension(): Link Here 
927
			action="append", type="existing_filename", default=[],
934
			action="append", type="existing_filename", default=[],
928
			help="UDM hook", metavar="<filename>")
935
			help="UDM hook", metavar="<filename>")
929
936
937
	parser.add_option("--udm_mapping", dest="udm_mapping",
938
			action="append", type="existing_filename", default=[],
939
			help="UDM mapping", metavar="<filename>")
940
930
	parser.add_option("--packagename", dest="packagename",
941
	parser.add_option("--packagename", dest="packagename",
931
			help="Package name")
942
			help="Package name")
932
	parser.add_option("--packageversion", dest="packageversion",
943
	parser.add_option("--packageversion", dest="packageversion",
 Lines 1041-1046   def ucs_registerLDAPExtension(): Link Here 
1041
			univentionUDMHook.register(udm_hook, opts, udm_passthrough_options)
1052
			univentionUDMHook.register(udm_hook, opts, udm_passthrough_options)
1042
			objects.append(univentionUDMHook)
1053
			objects.append(univentionUDMHook)
1043
1054
1055
	if opts.udm_mapping:
1056
		if UniventionUDMMapping.create_base_container(ucr, udm_passthrough_options) != 0:
1057
			sys.exit(1)
1058
1059
		for udm_mapping in opts.udm_mapping:
1060
			univentionUDMMapping = UniventionUDMMapping(ucr)
1061
			univentionUDMMapping.register(udm_mapping, opts, udm_passthrough_options)
1062
			objects.append(univentionUDMMapping)
1063
1044
	if opts.udm_module:
1064
	if opts.udm_module:
1045
		if UniventionUDMModule.create_base_container(ucr, udm_passthrough_options) != 0:
1065
		if UniventionUDMModule.create_base_container(ucr, udm_passthrough_options) != 0:
1046
			sys.exit(1)
1066
			sys.exit(1)
 Lines 1085-1090   def ucs_unregisterLDAPExtension(): Link Here 
1085
			action="append", type="string",
1105
			action="append", type="string",
1086
			help="UDM hook", metavar="<hook name>")
1106
			help="UDM hook", metavar="<hook name>")
1087
1107
1108
	parser.add_option("--udm_mapping", dest="udm_mapping",
1109
			action="append", type="string",
1110
			help="UDM mapping", metavar="<mapping name>")
1111
1088
	# parser.add_option("-v", "--verbose", action="count")
1112
	# parser.add_option("-v", "--verbose", action="count")
1089
1113
1090
	udm_passthrough_options = []
1114
	udm_passthrough_options = []
 Lines 1116-1121   def ucs_unregisterLDAPExtension(): Link Here 
1116
			univentionUDMHook = UniventionUDMHook(ucr)
1140
			univentionUDMHook = UniventionUDMHook(ucr)
1117
			univentionUDMHook.unregister(udm_hook, opts, udm_passthrough_options)
1141
			univentionUDMHook.unregister(udm_hook, opts, udm_passthrough_options)
1118
1142
1143
	if opts.udm_mapping:
1144
		for udm_mapping in opts.udm_mapping:
1145
			univentionUDMMapping = UniventionUDMMapping(ucr)
1146
			univentionUDMMapping.unregister(udm_mapping, opts, udm_passthrough_options)
1147
1119
	if opts.udm_syntax:
1148
	if opts.udm_syntax:
1120
		for udm_syntax in opts.udm_syntax:
1149
		for udm_syntax in opts.udm_syntax:
1121
			univentionUDMSyntax = UniventionUDMSyntax(ucr)
1150
			univentionUDMSyntax = UniventionUDMSyntax(ucr)
(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/settings/udm_mapping.py (+270 lines)
Line 0    Link Here 
1
# -*- coding: utf-8 -*-
2
#
3
# Univention Directory Manager Mappings
4
#  direcory manager module for UDM mappings
5
#
6
# Copyright 2017 Univention GmbH
7
#
8
# http://www.univention.de/
9
#
10
# All rights reserved.
11
#
12
# The source code of this program is made available
13
# under the terms of the GNU Affero General Public License version 3
14
# (GNU AGPL V3) as published by the Free Software Foundation.
15
#
16
# Binary versions of this program provided by Univention to you as
17
# well as other copyrighted, protected or trademarked materials like
18
# Logos, graphics, fonts, specific documentations and configurations,
19
# cryptographic keys etc. are subject to a license agreement between
20
# you and Univention and not subject to the GNU AGPL V3.
21
#
22
# In the case you use this program under the terms of the GNU AGPL V3,
23
# the program is provided in the hope that it will be useful,
24
# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
# GNU Affero General Public License for more details.
27
#
28
# You should have received a copy of the GNU Affero General Public
29
# License with the Debian GNU/Linux or Univention distribution in file
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
32
33
from univention.admin.layout import Tab, Group
34
import univention.admin.filter
35
import univention.admin.handlers
36
import univention.admin.password
37
import univention.admin.allocators
38
import univention.admin.localization
39
import apt
40
41
translation = univention.admin.localization.translation('univention.admin.handlers.settings')
42
_ = translation.translate
43
44
OC = "univentionUDMMapping"
45
46
module = 'settings/udm_mapping'
47
superordinate = 'settings/cn'
48
childs = 0
49
operations = ['add', 'edit', 'remove', 'search', 'move']
50
short_description = _('Settings: UDM Mapping')
51
long_description = ''
52
options = {}
53
property_descriptions = {
54
	'name': univention.admin.property(
55
		short_description=_('UDM mapping name'),
56
		long_description='',
57
		syntax=univention.admin.syntax.string,
58
		multivalue=False,
59
		include_in_default_search=True,
60
		options=[],
61
		required=True,
62
		may_change=True,
63
		identifies=True
64
	),
65
	'filename': univention.admin.property(
66
		short_description=_('UDM mapping file name'),
67
		long_description='',
68
		syntax=univention.admin.syntax.BaseFilename,
69
		multivalue=False,
70
		options=[],
71
		required=True,
72
		may_change=True,
73
		default='',
74
		identifies=False
75
	),
76
	'data': univention.admin.property(
77
		short_description=_('UDM mapping data'),
78
		long_description='',
79
		syntax=univention.admin.syntax.Base64Bzip2Text,
80
		multivalue=False,
81
		options=[],
82
		required=True,
83
		may_change=True,
84
		identifies=False
85
	),
86
	'active': univention.admin.property(
87
		short_description=_('Active'),
88
		long_description='',
89
		syntax=univention.admin.syntax.TrueFalseUp,
90
		default='FALSE',
91
		multivalue=False,
92
		options=[],
93
		required=False,
94
		may_change=True,
95
		identifies=False
96
	),
97
	'appidentifier': univention.admin.property(
98
		short_description=_('App identifier'),
99
		long_description='',
100
		syntax=univention.admin.syntax.TextArea,
101
		multivalue=True,
102
		options=[],
103
		required=False,
104
		may_change=True,
105
		identifies=False
106
	),
107
	'package': univention.admin.property(
108
		short_description=_('Software package'),
109
		long_description='',
110
		syntax=univention.admin.syntax.string,
111
		multivalue=False,
112
		options=[],
113
		required=False,
114
		may_change=True,
115
		identifies=False
116
	),
117
	'packageversion': univention.admin.property(
118
		short_description=_('Software package version'),
119
		long_description='',
120
		syntax=univention.admin.syntax.DebianPackageVersion,
121
		multivalue=False,
122
		options=[],
123
		required=False,
124
		may_change=True,
125
		identifies=False
126
	),
127
	'ucsversionstart': univention.admin.property(
128
		short_description=_('Minimal UCS version'),
129
		long_description='',
130
		syntax=univention.admin.syntax.UCSVersion,
131
		multivalue=False,
132
		options=[],
133
		required=False,
134
		may_change=True,
135
		identifies=False
136
	),
137
	'ucsversionend': univention.admin.property(
138
		short_description=_('Maximal UCS version'),
139
		long_description='',
140
		syntax=univention.admin.syntax.UCSVersion,
141
		multivalue=False,
142
		options=[],
143
		required=False,
144
		may_change=True,
145
		identifies=False
146
	),
147
	'messagecatalog': univention.admin.property(
148
		short_description=_('GNU message catalog for translations'),
149
		long_description='GNU message catalog (syntax: <language tag> <Base64 encoded GNU message catalog>)',
150
		syntax=univention.admin.syntax.Localesubdirname_and_GNUMessageCatalog,
151
		multivalue=True,
152
		include_in_default_search=False,
153
		options=[],
154
		required=False,
155
		may_change=True,
156
		identifies=False,
157
	),
158
}
159
160
layout = [
161
	Tab(_('General'), _('Basic values'), layout=[
162
		Group(_('General UDM mapping settings'), layout=[
163
			["name"],
164
			["filename"],
165
			["data"],
166
			["messagecatalog"],
167
		]),
168
		Group(_('Metadata'), layout=[
169
			["package"],
170
			["packageversion"],
171
			["appidentifier"],
172
		]),
173
		Group(_('UCS Version Dependencies'), layout=[
174
			["ucsversionstart"],
175
			["ucsversionend"],
176
		]),
177
		Group(_('Activated'), layout=[
178
			["active"],
179
		]),
180
	]),
181
]
182
183
mapping = univention.admin.mapping.mapping()
184
mapping.register('name', 'cn', None, univention.admin.mapping.ListToString)
185
mapping.register('filename', 'univentionUDMMappingFilename', None, univention.admin.mapping.ListToString)
186
mapping.register('data', 'univentionUDMMappingData', univention.admin.mapping.mapBase64, univention.admin.mapping.unmapBase64)
187
mapping.register('active', 'univentionUDMMappingActive', None, univention.admin.mapping.ListToString)
188
mapping.register('appidentifier', 'univentionAppIdentifier')
189
mapping.register('package', 'univentionOwnedByPackage', None, univention.admin.mapping.ListToString)
190
mapping.register('packageversion', 'univentionOwnedByPackageVersion', None, univention.admin.mapping.ListToString)
191
mapping.register('ucsversionstart', 'univentionUCSVersionStart', None, univention.admin.mapping.ListToString)
192
mapping.register('ucsversionend', 'univentionUCSVersionEnd', None, univention.admin.mapping.ListToString)
193
# messagecatalog is handled via object._post_map and object._post_unmap defined below
194
195
196
class object(univention.admin.handlers.simpleLdap):
197
	module = module
198
199
	def _ldap_addlist(self):
200
		ocs = ['top', 'univentionObjectMetadata', OC]
201
202
		return [
203
			('objectClass', ocs),
204
		]
205
206
	def _ldap_pre_modify(self):
207
		diff_keys = [key for key in self.info.keys() if self.info.get(key) != self.oldinfo.get(key) and key not in ('active', 'appidentifier')]
208
		if not diff_keys:  # check for trivial change
209
			return
210
		if not self.hasChanged('package'):
211
			old_version = self.oldinfo.get('packageversion', '0')
212
			if not apt.apt_pkg.version_compare(self['packageversion'], old_version) > -1:
213
				raise univention.admin.uexceptions.valueInvalidSyntax(_('packageversion: Version must not be lower than the current one.'))
214
215
	def _post_unmap(self, info, values):
216
		info['messagecatalog'] = []
217
		messagecatalog_ldap_attribute = "univentionMessageCatalog"
218
		messagecatalog_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (messagecatalog_ldap_attribute,)
219
		for ldap_attribute, value_list in values.items():
220
			if ldap_attribute.startswith(messagecatalog_ldap_attribute_and_tag_prefix):
221
				language_tag = ldap_attribute.split(messagecatalog_ldap_attribute_and_tag_prefix, 1)[1]
222
				mo_data_base64 = univention.admin.mapping.unmapBase64(value_list)
223
				info['messagecatalog'].append((language_tag, mo_data_base64))
224
		return info
225
226
	def _post_map(self, modlist, diff):
227
		messagecatalog_ldap_attribute = "univentionMessageCatalog"
228
		messagecatalog_ldap_attribute_and_tag_prefix = "%s;entry-lang-" % (messagecatalog_ldap_attribute,)
229
		for property_name, old_value, new_value in diff:
230
			if property_name == 'messagecatalog':
231
				old_dict = dict(old_value)
232
				new_dict = dict(new_value)
233
				for language_tag, old_mo_data_base64 in old_dict.items():
234
					ldap_attribute = ''.join((messagecatalog_ldap_attribute_and_tag_prefix, language_tag))
235
					new_mo_data_base64 = new_dict.get(language_tag)
236
					if not new_mo_data_base64:  # property value has been removed
237
						old_mo_data_binary = univention.admin.mapping.mapBase64(old_mo_data_base64)
238
						modlist.append((ldap_attribute, old_mo_data_binary, None))
239
					else:
240
						if new_mo_data_base64 != old_mo_data_base64:
241
							old_mo_data_binary = univention.admin.mapping.mapBase64(old_mo_data_base64)
242
							new_mo_data_binary = univention.admin.mapping.mapBase64(new_mo_data_base64)
243
							modlist.append((ldap_attribute, old_mo_data_binary, new_mo_data_binary))
244
				for language_tag, new_mo_data_base64 in new_dict.items():
245
					ldap_attribute = ''.join((messagecatalog_ldap_attribute_and_tag_prefix, language_tag))
246
					if not old_dict.get(language_tag):  # property value has been added
247
						new_mo_data_binary = univention.admin.mapping.mapBase64(new_mo_data_base64)
248
						modlist.append((ldap_attribute, None, new_mo_data_binary))
249
				break
250
		return modlist
251
252
253
def lookup(co, lo, filter_s, base='', superordinate=None, scope='sub', unique=False, required=False, timeout=-1, sizelimit=0):
254
	filter = univention.admin.filter.conjunction('&', [
255
		univention.admin.filter.expression('objectClass', OC),
256
	])
257
258
	if filter_s:
259
		filter_p = univention.admin.filter.parse(filter_s)
260
		univention.admin.filter.walk(filter_p, univention.admin.mapping.mapRewrite, arg=mapping)
261
		filter.expressions.append(filter_p)
262
263
	res = []
264
	for dn, attrs in lo.search(unicode(filter), base, scope, [], unique, required, timeout, sizelimit):
265
		res.append(object(co, lo, None, dn, attributes=attrs))
266
	return res
267
268
269
def identify(dn, attr, canonical=0):
270
	return OC in attr.get('objectClass', [])
(-)a/management/univention-ldap/schema/udm-extension.schema (+31 lines)
 Lines 116-118   objectclass ( univentionUDMExtensionObjectClass:3 NAME 'univentionUDMSyntax' Link Here 
116
		$ univentionMessageCatalog
116
		$ univentionMessageCatalog
117
		)
117
		)
118
	)
118
	)
119
120
### Definition for univentionUDMMapping
121
122
attributetype ( univentionUDMExtensionAttributeType:41 NAME 'univentionUDMMappingFilename'
123
	DESC 'UDM mapping filename'
124
	SINGLE-VALUE
125
	EQUALITY caseExactMatch
126
	SUBSTR caseExactSubstringsMatch
127
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
128
129
attributetype ( univentionUDMExtensionAttributeType:42 NAME 'univentionUDMMappingData'
130
	DESC 'UDM mapping data'
131
	SINGLE-VALUE
132
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.5 )
133
134
attributetype ( univentionUDMExtensionAttributeType:43 NAME 'univentionUDMMappingActive'
135
	DESC 'Flag indicating availability of the UDM mapping'
136
	SINGLE-VALUE
137
	EQUALITY booleanMatch
138
	SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 )
139
140
objectclass ( univentionUDMExtensionObjectClass:4 NAME 'univentionUDMMapping'
141
	DESC 'UCS UDM mapping'
142
	SUP 'univentionObjectMetadata' STRUCTURAL
143
	MUST ( cn )
144
	MAY (	univentionUDMMappingFilename
145
		$ univentionUDMMappingData
146
		$ univentionUDMMappingActive
147
		$ univentionMessageCatalog
148
		)
149
	)

Return to bug 43129