:py:mod:`dissect.util.ldap` =========================== .. py:module:: dissect.util.ldap Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.util.ldap.LogicalOperator dissect.util.ldap.ComparisonOperator dissect.util.ldap.SearchFilter Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.util.ldap.optimize_ldap_query .. py:exception:: InvalidQueryError Bases: :py:obj:`dissect.util.exceptions.Error` Common base class for all non-exit exceptions. .. py:class:: LogicalOperator Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: AND :value: '&' .. py:attribute:: OR :value: '|' .. py:attribute:: NOT :value: '!' .. py:class:: ComparisonOperator Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: GE :value: '>=' .. py:attribute:: LE :value: '<=' .. py:attribute:: GT :value: '>' .. py:attribute:: LT :value: '<' .. py:attribute:: EQ :value: '=' .. py:attribute:: APPROX :value: '~=' .. py:attribute:: BIT :value: ':=' .. py:attribute:: EXTENDED :value: ':' .. py:class:: SearchFilter(query: str) Represents an LDAP search filter (simple or nested). :param query: The LDAP search filter string. .. py:attribute:: query :type: str .. py:attribute:: children :type: list[SearchFilter] :value: [] .. py:attribute:: operator :type: LogicalOperator | ComparisonOperator | None :value: None .. py:attribute:: attribute :type: str | None :value: None .. py:attribute:: value :type: str | None :value: None .. py:method:: __repr__() -> str .. py:method:: parse(query: str, optimize: bool = True) -> SearchFilter :classmethod: Parse an LDAP query into a filter object, with optional optimization. .. py:method:: is_nested() -> bool Return whether the filter is nested (i.e., contains logical operators and child filters). .. py:method:: format() -> str Format the search filter back into an LDAP query string. .. py:function:: optimize_ldap_query(query: SearchFilter) -> tuple[SearchFilter, int] Optimize an LDAP query in-place. Removes redundant conditions and sorts filters and conditions based on how specific they are. :param query: The LDAP query to optimize. :returns: A tuple containing the optimized LDAP query and its weight.