From 7890f4c867e0057c76a77a78b20a64f1cd26262c Mon Sep 17 00:00:00 2001 From: Stefan Andersson Date: Fri, 3 Feb 2012 11:41:26 +0100 Subject: [PATCH] Added support for abandon request Conflicts: ldaptor/test/test_pureldap.py --- ldaptor/protocols/pureldap.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/ldaptor/protocols/pureldap.py b/ldaptor/protocols/pureldap.py index 65b2ec99..8ef4187f 100644 --- a/ldaptor/protocols/pureldap.py +++ b/ldaptor/protocols/pureldap.py @@ -40,6 +40,9 @@ def escape(s): s = s.replace('\0', r'\00') return s +class LDAPInteger(BERInteger): + pass + class LDAPString(BEROctetString): pass @@ -1137,9 +1140,33 @@ class LDAPModifyDNResponse(LDAPResult): #class LDAPCompareResponse(LDAPProtocolResponse): #class LDAPCompareRequest(LDAPProtocolRequest): -#class LDAPAbandonRequest(LDAPProtocolRequest): -# needs_answer=0 +class LDAPAbandonRequest(LDAPProtocolRequest, LDAPInteger): + tag = CLASS_APPLICATION|0x10 + needs_answer=0 + + def __init__(self, value=None, id=None, tag=None): + """ + Initialize the object + + l=LDAPAbandonRequest(id=1) + """ + if id is None and value is not None: + id = value + LDAPProtocolRequest.__init__(self) + LDAPInteger.__init__(self, value=id, tag=tag) + + def __str__(self): + return LDAPInteger.__str__(self) + + def __repr__(self): + if self.tag==self.__class__.tag: + return self.__class__.__name__+"(id=%s)" \ + %repr(self.value) + else: + return self.__class__.__name__ \ + +"(id=%s, tag=%d)" \ + %(repr(self.value), self.tag) class LDAPOID(BEROctetString): pass @@ -1347,4 +1374,5 @@ class LDAPBERDecoderContext(BERDecoderContext): LDAPExtendedResponse.tag: LDAPExtendedResponse, LDAPModifyDNRequest.tag: LDAPModifyDNRequest, LDAPModifyDNResponse.tag: LDAPModifyDNResponse, + LDAPAbandonRequest.tag: LDAPAbandonRequest, }