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.

rfc2696.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """
  2. """
  3. # Created on 2013.10.15
  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 pyasn1.type.univ import OctetString, Integer, Sequence
  25. from pyasn1.type.namedtype import NamedTypes, NamedType
  26. from pyasn1.type.constraint import ValueRangeConstraint
  27. from .controls import build_control
  28. # constants
  29. # maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) --
  30. MAXINT = Integer(2147483647)
  31. # constraints
  32. rangeInt0ToMaxConstraint = ValueRangeConstraint(0, MAXINT)
  33. class Integer0ToMax(Integer):
  34. subtypeSpec = Integer.subtypeSpec + rangeInt0ToMaxConstraint
  35. class Size(Integer0ToMax):
  36. # Size INTEGER (0..maxInt)
  37. pass
  38. class Cookie(OctetString):
  39. # cookie OCTET STRING
  40. pass
  41. class RealSearchControlValue(Sequence):
  42. # realSearchControlValue ::= SEQUENCE {
  43. # size INTEGER (0..maxInt),
  44. # -- requested page size from client
  45. # -- result set size estimate from server
  46. # cookie OCTET STRING
  47. componentType = NamedTypes(NamedType('size', Size()),
  48. NamedType('cookie', Cookie()))
  49. def paged_search_control(criticality=False, size=10, cookie=None):
  50. control_value = RealSearchControlValue()
  51. control_value.setComponentByName('size', Size(size))
  52. control_value.setComponentByName('cookie', Cookie(cookie if cookie else ''))
  53. return build_control('1.2.840.113556.1.4.319', criticality, control_value)