2
# alias.py - lookup functions for aliasnet addresses
4
# Copyright (C) 2010, 2011 Arthur de Jong
6
# This library is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU Lesser General Public
8
# License as published by the Free Software Foundation; either
9
# version 2.1 of the License, or (at your option) any later version.
11
# This library is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# Lesser General Public License for more details.
16
# You should have received a copy of the GNU Lesser General Public
17
# License along with this library; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27
attmap = common.Attributes(cn='cn', rfc822MailMember='rfc822MailMember')
28
filter = '(objectClass=nisMailAlias)'
31
class AliasRequest(common.Request):
33
def write(self, dn, attributes, parameters):
34
# get name and check against requested name
35
names = attributes['cn']
37
logging.error('Error: entry %s does not contain %s value', dn, attmap['cn'])
39
if 'cn' in parameters:
40
if parameters['cn'].lower() not in (x.lower() for x in names):
42
names = ( parameters['cn'], )
43
# get the members of the alias
44
members = attributes['rfc822MailMember']
46
logging.error('Error: entry %s does not contain %s value', dn, attmap['rfc822MailMember'])
50
self.fp.write_int32(constants.NSLCD_RESULT_BEGIN)
51
self.fp.write_string(name)
52
self.fp.write_stringlist(members)
55
class AliasByNameRequest(AliasRequest):
57
action = constants.NSLCD_ACTION_ALIAS_BYNAME
59
def read_parameters(self, fp):
60
return dict(cn=fp.read_string())
63
class AliasAllRequest(AliasRequest):
65
action = constants.NSLCD_ACTION_ALIAS_ALL