|
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 |
|