View | Details | Raw Unified | Return to bug 40765
Collapse All | Expand All

(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printer.py (-4 / +4 lines)
 Lines 31-36    Link Here 
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
import re
33
import re
34
import ldap.filter
34
35
35
from univention.admin.layout import Tab, Group
36
from univention.admin.layout import Tab, Group
36
import univention.admin.uldap
37
import univention.admin.uldap
 Lines 324-332   def _ldap_pre_modify(self):# check for membership in a quota-printerclass Link Here 
324
		# cut off '/' at the beginning of the destination if it exists and protocol is file:/
325
		# cut off '/' at the beginning of the destination if it exists and protocol is file:/
325
		if self[ 'uri' ] and self[ 'uri' ][ 0 ] == 'file:/' and self[ 'uri' ][ 1 ][ 0 ] == '/':
326
		if self[ 'uri' ] and self[ 'uri' ][ 0 ] == 'file:/' and self[ 'uri' ][ 1 ][ 0 ] == '/':
326
			self[ 'uri' ][ 1 ] = re.sub( r'^/+', '', self[ 'uri' ][ 1 ] )
327
			self[ 'uri' ][ 1 ] = re.sub( r'^/+', '', self[ 'uri' ][ 1 ] )
327
		if self.hasChanged('setQuota') and self.info['setQuota'] == '0':
328
		if self.hasChanged('setQuota') and self.info['setQuota'] == '0' and self.info['spoolHost']:
328
			printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterQuotaSupport=1)(univentionPrinterSpoolHost=%s))'
329
			printergroups = self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterQuotaSupport=1)(|%s))' % (''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost'])))
329
										   % self.info['spoolHost'])
330
			group_cn=[]
330
			group_cn=[]
331
			for pg_dn in printergroups:
331
			for pg_dn in printergroups:
332
				member_list = self.lo.get(pg_dn, attr=['univentionPrinterGroupMember','cn'])
332
				member_list = self.lo.get(pg_dn, attr=['univentionPrinterGroupMember','cn'])
 Lines 338-344   def _ldap_pre_modify(self):# check for membership in a quota-printerclass Link Here 
338
338
339
339
340
	def _ldap_pre_remove(self): # check for last member in printerclass
340
	def _ldap_pre_remove(self): # check for last member in printerclass
341
		printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterSpoolHost=%s))'%self.info['spoolHost'])
341
		printergroups = self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(|%s))' % (''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost'])))
342
		rm_attrib=[]
342
		rm_attrib=[]
343
		for pg_dn in printergroups:
343
		for pg_dn in printergroups:
344
			member_list=self.lo.search( base=pg_dn, attr=['univentionPrinterGroupMember','cn'])
344
			member_list=self.lo.search( base=pg_dn, attr=['univentionPrinterGroupMember','cn'])
(-)a/management/univention-directory-manager-modules/modules/univention/admin/handlers/shares/printergroup.py (-7 / +7 lines)
 Lines 30-35    Link Here 
30
# /usr/share/common-licenses/AGPL-3; if not, see
30
# /usr/share/common-licenses/AGPL-3; if not, see
31
# <http://www.gnu.org/licenses/>.
31
# <http://www.gnu.org/licenses/>.
32
32
33
import ldap.filter
34
33
from univention.admin.layout import Tab, Group
35
from univention.admin.layout import Tab, Group
34
import univention.admin.uldap
36
import univention.admin.uldap
35
import univention.admin.syntax
37
import univention.admin.syntax
 Lines 192-198   def _ldap_modlist(self):# check for membership in a quota-printerclass Link Here 
192
				raise univention.admin.uexceptions.leavePrinterGroup(_('%(name)s is member of the following quota printer groups %(groups)s') % {'name': self.info['name'], 'groups': ', '.join(group_cn)})
194
				raise univention.admin.uexceptions.leavePrinterGroup(_('%(name)s is member of the following quota printer groups %(groups)s') % {'name': self.info['name'], 'groups': ', '.join(group_cn)})
193
		elif self.info.get( 'setQuota', None ) == '1':
195
		elif self.info.get( 'setQuota', None ) == '1':
194
			for member_cn in self.info['groupMember']:
196
			for member_cn in self.info['groupMember']:
195
				member_dn=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(univentionPrinterSpoolHost=%s)(cn=%s)(univentionPrinterQuotaSupport=1))' % (self.info['spoolHost'][0], member_cn))
197
				member_dn=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(|%s)(cn=%s)(univentionPrinterSpoolHost=%s)(cn=%s)(univentionPrinterQuotaSupport=1))' % (''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost']), ldap.filter.escape_filter_chars(member_cn)))
196
				if len(member_dn) < 1:
198
				if len(member_dn) < 1:
197
					raise univention.admin.uexceptions.leavePrinterGroup, _('%s is disabled for quota support. ') % member_cn
199
					raise univention.admin.uexceptions.leavePrinterGroup, _('%s is disabled for quota support. ') % member_cn
198
		if self.hasChanged('groupMember'):
200
		if self.hasChanged('groupMember'):
 Lines 200-206   def _ldap_modlist(self):# check for membership in a quota-printerclass Link Here 
200
		return univention.admin.handlers.simpleLdap._ldap_modlist(self)
202
		return univention.admin.handlers.simpleLdap._ldap_modlist(self)
201
203
202
	def _ldap_pre_remove(self): # check for last member in printerclass on same spoolhost
204
	def _ldap_pre_remove(self): # check for last member in printerclass on same spoolhost
203
		printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(univentionPrinterSpoolHost=%s))' % self.info['spoolHost'])
205
		printergroups=self.lo.searchDn(filter='(&(objectClass=univentionPrinterGroup)(|%s))' % ''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost']))
204
		rm_attrib=[]
206
		rm_attrib=[]
205
		for pg_dn in printergroups:
207
		for pg_dn in printergroups:
206
			member_list=self.lo.search( base=pg_dn, attr=['univentionPrinterGroupMember','cn'])
208
			member_list=self.lo.search( base=pg_dn, attr=['univentionPrinterGroupMember','cn'])
 Lines 218-229   def _ldap_pre_remove(self): # check for last member in printerclass on same spoo Link Here 
218
220
219
	def isValidPrinterObject(self): # check printer on current spoolhost
221
	def isValidPrinterObject(self): # check printer on current spoolhost
220
		for member in self.info['groupMember']:
222
		for member in self.info['groupMember']:
221
			spoolhosts = '(|'
222
			for host in self.info[ 'spoolHost' ]:
223
				spoolhosts += "(univentionPrinterSpoolHost=%s)" % host
224
			spoolhosts += ')'
225
223
226
			test=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(cn=%s)%s)' % ( member, spoolhosts ) )
224
			spoolhosts = '(|%s)' % ''.join(ldap.filter.filter_format('(univentionPrinterSpoolHost=%s)', [x]) for x in self.info['spoolHost'])
225
226
			test=self.lo.searchDn(filter='(&(objectClass=univentionPrinter)(cn=%s)%s)' % (ldap.filter.escape_filter_chars(member), spoolhosts ) )
227
			if len(test) < 1:
227
			if len(test) < 1:
228
				raise univention.admin.uexceptions.notValidPrinter(_('%(name)s is not a valid printer on Spoolhost %(host)s.') % {'name': member, 'host': self.info['spoolHost']})
228
				raise univention.admin.uexceptions.notValidPrinter(_('%(name)s is not a valid printer on Spoolhost %(host)s.') % {'name': member, 'host': self.info['spoolHost']})
229
229

Return to bug 40765