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.

rfc4527.py 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """
  2. """
  3. # Created on 2016.12.23
  4. #
  5. # Author: Giovanni Cannata
  6. #
  7. # Copyright 2013 - 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 .. import NO_ATTRIBUTES, ALL_ATTRIBUTES, STRING_TYPES
  25. from ..operation.search import build_attribute_selection
  26. from .controls import build_control
  27. def _read_control(oid, attributes, criticality=False):
  28. if not attributes:
  29. attributes = [NO_ATTRIBUTES]
  30. elif attributes == ALL_ATTRIBUTES:
  31. attributes = [ALL_ATTRIBUTES]
  32. if isinstance(attributes, STRING_TYPES):
  33. attributes = [attributes]
  34. value = build_attribute_selection(attributes, None)
  35. return build_control(oid, criticality, value)
  36. def pre_read_control(attributes, criticality=False):
  37. """Create a pre-read control for a request.
  38. When passed as a control to the controls parameter of an operation, it will
  39. return the value in `Connection.result` before the operation took place.
  40. """
  41. return _read_control('1.3.6.1.1.13.1', attributes, criticality)
  42. def post_read_control(attributes, criticality=False):
  43. """Create a post-read control for a request.
  44. When passed as a control to the controls parameter of an operation, it will
  45. return the value in `Connection.result` after the operation took place.
  46. """
  47. return _read_control('1.3.6.1.1.13.2', attributes, criticality)