Exemple #1
0
def get_controls(controls):
    for control_type, criticality, control_value in controls:
        if control_type == PagedResultsControl.control_type:
            return [PagedResultsControl.fromBER(criticality, control_value)]
        elif criticality:
            raise ldaperrors.LDAPUnavailableCriticalExtension(
                'Unknown control %s' % control_type)
    return []
Exemple #2
0
    def fromBER(cls, criticality, control_value):
        ber_context = pureber.BERDecoderContext()
        obj, _ = pureber.berDecodeObject(ber_context, control_value)
        size = obj[0].value
        cookie = obj[1].value

        if size <= 0:
            raise ldaperrors.LDAPUnavailableCriticalExtension(
                'Page size must be greater than 0')

        if cookie:
            obj, _ = pureber.berDecodeObject(ber_context, cookie)
            remain_count = obj[0].value
            last_id = obj[1].value
        else:
            remain_count = None
            last_id = 0
        return cls(criticality, size, remain_count, last_id)
Exemple #3
0
 def checkControls(self, controls):
     if controls is not None:
         for controlType, criticality, controlValue in controls:
             if criticality:
                 raise ldaperrors.LDAPUnavailableCriticalExtension(
                     'Unknown control %s' % controlType)