codekingpro/portable-devtools
114k
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 CreateGroupTypeRequestValue, CreateGroupTypeResponseValue, GroupingControlValue
28from ...protocol.controls import build_control
29
30
31class StartTransaction(ExtendedOperation):
32 def config(self):
33 self.request_name = '2.16.840.1.113719.1.27.103.1'
34 self.response_name = '2.16.840.1.113719.1.27.103.1'
35 self.request_value = CreateGroupTypeRequestValue()
36 self.asn1_spec = CreateGroupTypeResponseValue()
37
38 def __init__(self, connection, controls=None):
39 ExtendedOperation.__init__(self, connection, controls) # calls super __init__()
40 self.request_value['createGroupType'] = '2.16.840.1.113719.1.27.103.7' # transactionGroupingType
41
42 def populate_result(self):
43 self.result['cookie'] = int(self.decoded_response['createGroupCookie'])
44 try:
45 self.result['value'] = self.decoded_response['createGroupValue']
46 except TypeError:
47 self.result['value'] = None
48
49 def set_response(self):
50 try:
51 grouping_cookie_value = GroupingControlValue()
52 grouping_cookie_value['groupingCookie'] = self.result['cookie']
53 self.response_value = build_control('2.16.840.1.113719.1.27.103.7', True, grouping_cookie_value, encode_control_value=True) # groupingControl
54 except TypeError:
55 self.response_value = None
56
57 