LDAP Filter¶
LDAP filter expressions.
- class freeiam.ldap.filter.AND(expressions: list[Expression | Token], *, sep: Token | None = None)[source]¶
Bases:
OperatorA group of AND conjunction expressions
(&(...)(...)).- expression = '&'¶
- operator(a, b, /)¶
Same as a & b.
- class freeiam.ldap.filter.ApproximateMatch(attr: str, value: str, is_escaped: bool = False)[source]¶
Bases:
ComparisonCompare approximately (attr~=value).
- attr¶
- expression = '~='¶
- is_escaped¶
- raw_value¶
- class freeiam.ldap.filter.Comparison(attr: str, value: str, is_escaped: bool = False)[source]¶
Bases:
ExpressionBase class for comparison operators.
- attr¶
- property escaped: str¶
Get the value in a encoded/escaped form.
- expression = ''¶
- is_escaped¶
- operator: Callable[[...], bool] | None = None¶
- raw_value¶
- property value: str¶
Get the value in a decoded form.
- class freeiam.ldap.filter.EqualityMatch(attr: str, value: str, is_escaped: bool = False)[source]¶
Bases:
ComparisonCompare for equality (attr=value).
- attr¶
- expression = '='¶
- is_escaped¶
- operator(a, b, /)¶
Same as a == b.
- raw_value¶
- class freeiam.ldap.filter.ExtensibleMatch(attr: str, value: str, dn: str | None, matchingrule: str | None, is_escaped: bool = True)[source]¶
Bases:
ComparisonCompare with extensible match (attr:dn:rule:=value, optional: dn / Matching Rule OID).
- attr¶
- dn¶
- expression = ':='¶
- is_escaped¶
- matchingrule¶
- raw_value¶
- class freeiam.ldap.filter.Filter(filter_expr: str | None, *, strict: bool = False, _debug: bool = False)[source]¶
Bases:
objectA LDAP Filter according to RFC 4515.
- RE_HEXESCAPE = re.compile('\\\\([0-9A-Fa-f]{2})')¶
- ast¶
- classmethod attr(attr: str, dn: str | None = None, matchingrule: str | None = None) Attribute[source]¶
Get attribute for comparison.
- error() FilterError[source]¶
Get FilterError.
- classmethod escape(value: str, escape_mode: EscapeMode = EscapeMode.RESTRICTED) str[source]¶
Escape LDAP filter characters.
- classmethod escape_formatted(format_string: str, values: Sequence[str]) str[source]¶
Escape LDAP filter characters in format string.
- filter_expr¶
- classmethod from_format(format_string: str, values: list[str]) Self[source]¶
Get a Filter from a filter format string.
- classmethod get_approx(attr: str, value: str) ApproximateMatch[source]¶
Get ApproximateMatch.
- classmethod get_eq(attr: str, value: str) EqualityMatch[source]¶
Get EqualityMatch.
- classmethod get_extensible(attr: str, dn: str | None, matchingrule: str | None, value: str) ExtensibleMatch[source]¶
Get ExtensibleMatch.
- classmethod get_gt(attr: str, value: str | int) NOT | GreaterOrEqual[source]¶
Get greather then equivialent.
- classmethod get_gt_eq(attr: str, value: str | int) GreaterOrEqual[source]¶
Get GreaterOrEqual.
- classmethod get_lt(attr: str, value: str | int) NOT | LessOrEqual[source]¶
Get Lower than equivialent.
- classmethod get_lt_eq(attr: str, value: str | int) LessOrEqual[source]¶
Get LessOrEqual.
- classmethod get_pres(attr: str) PresenceMatch[source]¶
Get PresenceMatch.
- classmethod get_substring(attr: str, *values: str) SubstringMatch[source]¶
Get SubstringMatch.
- parser = Lark(open('<string>'), parser='earley', lexer='dynamic', ...)¶
- property root: Expression | None¶
The first object in the filter.
- class freeiam.ldap.filter.GreaterOrEqual(attr: str, value: str, is_escaped: bool = False)[source]¶
Bases:
ComparisonCompare for greater or equals (attr>=value).
- attr¶
- expression = '>='¶
- is_escaped¶
- operator(a, b, /)¶
Same as a >= b.
- raw_value¶
- class freeiam.ldap.filter.LessOrEqual(attr: str, value: str, is_escaped: bool = False)[source]¶
Bases:
ComparisonCompare for less than or equals (attr<=value).
- attr¶
- expression = '<='¶
- is_escaped¶
- operator(a, b, /)¶
Same as a <= b.
- raw_value¶
- class freeiam.ldap.filter.NOT(expressions: list[Expression | Token], *, sep: Token | None = None)[source]¶
Bases:
OperatorA group of NOT negation expressions
(!( ... )).- expression = '!'¶
- operator(a, /)¶
Same as not a.
- class freeiam.ldap.filter.OR(expressions: list[Expression | Token], *, sep: Token | None = None)[source]¶
Bases:
OperatorA group of OR disjunction expressions
(|(...)(...)).- expression = '|'¶
- operator(a, b, /)¶
Same as a | b.
- class freeiam.ldap.filter.Operator(expressions: list[Expression | Token], *, sep: Token | None = None)[source]¶
Bases:
GroupA logical operator.
- class freeiam.ldap.filter.PresenceMatch(attr: str, value: str, is_escaped: bool = False)[source]¶
Bases:
ComparisonCompare for presence (attr=*).
- attr¶
- expression = '=*'¶
- is_escaped¶
- raw_value¶
- class freeiam.ldap.filter.SubstringMatch(attr: str, value: str, is_escaped: bool = False)[source]¶
Bases:
ComparisonCompare substring match (attr=val*).
- attr¶
- expression = '='¶
- is_escaped¶
- operator(a, b, /)¶
Same as b in a (note reversed operands).
- raw_value¶
- property values: tuple[str, ...]¶
Get substring match values.