Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

startTransaction.py 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. """
  2. """
  3. # Created on 2016.04.14
  4. #
  5. # Author: Giovanni Cannata
  6. #
  7. # Copyright 2016 - 2018 Giovanni Cannata
  8. #
  9. # This file is part of ldap3.
  10. #
  11. # ldap3 is free software: you can redistribute it and/or modify
  12. # it under the terms of the GNU Lesser General Public License as published
  13. # by the Free Software Foundation, either version 3 of the License, or
  14. # (at your option) any later version.
  15. #
  16. # ldap3 is distributed in the hope that it will be useful,
  17. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. # GNU Lesser General Public License for more details.
  20. #
  21. # You should have received a copy of the GNU Lesser General Public License
  22. # along with ldap3 in the COPYING and COPYING.LESSER files.
  23. # If not, see <http://www.gnu.org/licenses/>.
  24. from ...extend.operation import ExtendedOperation
  25. from ...protocol.novell import CreateGroupTypeRequestValue, CreateGroupTypeResponseValue, GroupingControlValue
  26. from ...protocol.controls import build_control
  27. class StartTransaction(ExtendedOperation):
  28. def config(self):
  29. self.request_name = '2.16.840.1.113719.1.27.103.1'
  30. self.response_name = '2.16.840.1.113719.1.27.103.1'
  31. self.request_value = CreateGroupTypeRequestValue()
  32. self.asn1_spec = CreateGroupTypeResponseValue()
  33. def __init__(self, connection, controls=None):
  34. ExtendedOperation.__init__(self, connection, controls) # calls super __init__()
  35. self.request_value['createGroupType'] = '2.16.840.1.113719.1.27.103.7' # transactionGroupingType
  36. def populate_result(self):
  37. self.result['cookie'] = int(self.decoded_response['createGroupCookie'])
  38. try:
  39. self.result['value'] = self.decoded_response['createGroupValue']
  40. except TypeError:
  41. self.result['value'] = None
  42. def set_response(self):
  43. try:
  44. grouping_cookie_value = GroupingControlValue()
  45. grouping_cookie_value['groupingCookie'] = self.result['cookie']
  46. self.response_value = build_control('2.16.840.1.113719.1.27.103.7', True, grouping_cookie_value, encode_control_value=True) # groupingControl
  47. except TypeError:
  48. self.response_value = None