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.

persistentSearch.py 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. """
  2. """
  3. # Created on 2016.07.09
  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 pyasn1.type.namedtype import NamedTypes, NamedType, OptionalNamedType
  25. from pyasn1.type.namedval import NamedValues
  26. from pyasn1.type.univ import Sequence, Integer, Boolean, Enumerated
  27. from .rfc4511 import LDAPDN
  28. from .controls import build_control
  29. class PersistentSearchControl(Sequence):
  30. # PersistentSearch ::= SEQUENCE {
  31. # changeTypes INTEGER,
  32. # changesOnly BOOLEAN,
  33. # returnECs BOOLEAN
  34. # }
  35. componentType = NamedTypes(NamedType('changeTypes', Integer()),
  36. NamedType('changesOnly', Boolean()),
  37. NamedType('returnECs', Boolean())
  38. )
  39. class ChangeType(Enumerated):
  40. # changeType ENUMERATED {
  41. # add (1),
  42. # delete (2),
  43. # modify (4),
  44. # modDN (8)
  45. # }
  46. namedValues = NamedValues(('add', 1),
  47. ('delete', 2),
  48. ('modify', 4),
  49. ('modDN', 8))
  50. class EntryChangeNotificationControl(Sequence):
  51. # EntryChangeNotification ::= SEQUENCE {
  52. # changeType ENUMERATED {
  53. # add (1),
  54. # delete (2),
  55. # modify (4),
  56. # modDN (8)
  57. # },
  58. # previousDN LDAPDN OPTIONAL, -- modifyDN ops. only
  59. # changeNumber INTEGER OPTIONAL -- if supported
  60. # }
  61. # tagSet = TagSet()
  62. # tagSet = Sequence.tagSet.tagImplicitly(Tag(tagClassUniversal, tagFormatConstructed, 16))
  63. componentType = NamedTypes(NamedType('changeType', ChangeType()),
  64. OptionalNamedType('previousDN', LDAPDN()),
  65. OptionalNamedType('changeNumber', Integer())
  66. )
  67. def persistent_search_control(change_types, changes_only=True, return_ecs=True, criticality=False):
  68. control_value = PersistentSearchControl()
  69. control_value.setComponentByName('changeTypes', Integer(change_types))
  70. control_value.setComponentByName('changesOnly', Boolean(changes_only))
  71. control_value.setComponentByName('returnECs', Boolean(return_ecs))
  72. return build_control('2.16.840.1.113730.3.4.3', criticality, control_value)