From 330a28040095fff67e9cb105019f3b4cb7cb5f0e Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Mon, 12 Dec 2011 21:53:10 +0000 Subject: move check of required attributes and other common tests to the Request.handle_entry() method git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1570 ef36b2f9-881f-0410-afb5-c4e39611909c --- pynslcd/host.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'pynslcd/host.py') diff --git a/pynslcd/host.py b/pynslcd/host.py index 85e88a6..c2f8074 100644 --- a/pynslcd/host.py +++ b/pynslcd/host.py @@ -30,18 +30,14 @@ filter = '(objectClass=ipHost)' class HostRequest(common.Request): + canonical_first = ('cn', ) + required = ('cn', ) + def write(self, dn, attributes, parameters): - hostname = common.get_rdn_value(dn, attmap['cn']) + # get values hostnames = attributes['cn'] - if not hostnames: - print 'Error: entry %s does not contain %s value' % ( dn, attmap['cn'] ) - if not hostname: - hostname = hostnames.pop(0) - elif hostname in hostnames: - hostnames.remove(hostname) + hostname = hostnames.pop(0) addresses = attributes['ipHostNumber'] - if not addresses: - print 'Error: entry %s does not contain %s value' % ( dn, attmap['ipHostNumber'] ) # write result self.fp.write_int32(constants.NSLCD_RESULT_BEGIN) self.fp.write_string(hostname) -- cgit v1.2.3