/usr/share/web2ldap/pylib/ldaputil/controls.py is in web2ldap 1.1.43~dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | # -*- coding: utf-8 -*-
"""
ldaputil.controls - basic LDAP functions
(c) by Michael Stroeder <michael@stroeder.com>
This module is distributed under the terms of the
GPL (GNU GENERAL PUBLIC LICENSE) Version 2
(see http://www.gnu.org/copyleft/gpl.html)
"""
import ldap.controls.readentry
from ldap.controls.simple import ValueLessRequestControl,ResponseControl
from pyasn1_modules.rfc2251 import LDAPDN,PartialAttributeList,SearchResultEntry
from pyasn1.type import tag,namedtype,namedval,univ
from pyasn1.codec.ber import decoder
from pyasn1.error import PyAsn1Error
class ReadEntryControl(ldap.controls.readentry.ReadEntryControl):
class OpenLDAPITS6899SearchResultEntry(univ.Sequence):
"""
This is an ASN.1 description of SearchResultEntry not compliant to LDAPv3
which implements a work-around for OpenLDAP's ITS#6899
"""
tagSet = univ.Sequence.tagSet # work-around: instead of implicit tagging
componentType = namedtype.NamedTypes(
namedtype.NamedType('objectName', LDAPDN()),
namedtype.NamedType('attributes', PartialAttributeList())
)
def decodeControlValue(self,encodedControlValue):
try:
decodedEntry,_ = decoder.decode(encodedControlValue,asn1Spec=SearchResultEntry())
except PyAsn1Error,e:
decodedEntry,_ = decoder.decode(encodedControlValue,asn1Spec=self.OpenLDAPITS6899SearchResultEntry())
self.dn = str(decodedEntry[0])
self.entry = {}
for attr in decodedEntry[1]:
self.entry[str(attr[0])] = [ str(attr_value) for attr_value in attr[1] ]
class PreReadControl(ReadEntryControl):
controlType = ldap.CONTROL_PRE_READ
# override python-ldap's default implementation
ldap.controls.KNOWN_RESPONSE_CONTROLS[PreReadControl.controlType] = PreReadControl
class PostReadControl(ReadEntryControl):
controlType = ldap.CONTROL_POST_READ
# override python-ldap's default implementation
ldap.controls.KNOWN_RESPONSE_CONTROLS[PostReadControl.controlType] = PostReadControl
class SearchNoOpControl(ValueLessRequestControl,ResponseControl):
"""
No-op control attached for search operations implementing count operation
see http://www.openldap.org/its/index.cgi?findid=6598
"""
controlType = '1.3.6.1.4.1.4203.666.5.18'
def __init__(self,criticality=False):
self.criticality = criticality
class SearchNoOpControlValue(univ.Sequence):
pass
def decodeControlValue(self,encodedControlValue):
decodedValue,_ = decoder.decode(encodedControlValue,asn1Spec=self.SearchNoOpControlValue())
self.resultCode = int(decodedValue[0])
self.numSearchResults = int(decodedValue[1])
self.numSearchContinuations = int(decodedValue[2])
ldap.controls.KNOWN_RESPONSE_CONTROLS[SearchNoOpControl.controlType] = SearchNoOpControl
|