Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
endTransaction.py59 linesDownload Raw Back to novell
1"""
2"""
3
4# Created on 2016.04.14
5#
6# Author: Giovanni Cannata
7#
8# Copyright 2016 - 2020 Giovanni Cannata
9#
10# This file is part of ldap3.
11#
12# ldap3 is free software: you can redistribute it and/or modify
13# it under the terms of the GNU Lesser General Public License as published
14# by the Free Software Foundation, either version 3 of the License, or
15# (at your option) any later version.
16#
17# ldap3 is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20# GNU Lesser General Public License for more details.
21#
22# You should have received a copy of the GNU Lesser General Public License
23# along with ldap3 in the COPYING and COPYING.LESSER files.
24# If not, see <http://www.gnu.org/licenses/>.
25
26from ...extend.operation import ExtendedOperation
27from ...protocol.novell import EndGroupTypeRequestValue, EndGroupTypeResponseValue, Sequence
28from ...utils.asn1 import decoder
29
30
31class EndTransaction(ExtendedOperation):
32    def config(self):
33        self.request_name = '2.16.840.1.113719.1.27.103.2'
34        self.response_name = '2.16.840.1.113719.1.27.103.2'
35        self.request_value = EndGroupTypeRequestValue()
36        self.asn1_spec = EndGroupTypeResponseValue()
37
38    def __init__(self, connection, commit=True, controls=None):
39        if controls and len(controls) == 1:
40            group_cookie = decoder.decode(controls[0][2], asn1Spec=Sequence())[0][0]  # get the cookie from the built groupingControl
41        else:
42            group_cookie = None
43        controls = None
44
45        ExtendedOperation.__init__(self, connection, controls)  # calls super __init__()
46        if group_cookie:
47            self.request_value['endGroupCookie'] = group_cookie  # transactionGroupingType
48            if not commit:
49                self.request_value['endGroupValue'] = ''  # an empty endGroupValue means abort transaction
50
51    def populate_result(self):
52        try:
53            self.result['value'] = self.decoded_response['endGroupValue']
54        except TypeError:
55            self.result['value'] = None
56
57    def set_response(self):
58        self.response_value = self.result
59 
codekingpro/portable-devtools · Team Ai