paddle v0.1.4 Paddle.Filters View Source
Module used internally by Paddle to manipulate LDAP filters.
Link to this section Summary
Functions
Construct a filter that matches a list of objectClasses
Construct a eldap filter from the given keyword list or map
Merge two filters with an “and” operation
Link to this section Types
Link to this section Functions
Construct a filter that matches a list of objectClasses.
Examples:
iex> Paddle.Filters.class_filter ["posixAccount", "account"]
{:and,
[equalityMatch: {:AttributeValueAssertion, 'objectClass', 'posixAccount'},
equalityMatch: {:AttributeValueAssertion, 'objectClass', 'account'}]}
Link to this function
construct_filter(filter)
View Source
construct_filter(filter()) :: eldap_filter()
Construct a eldap filter from the given keyword list or map.
If given an :eldap
filter (a tuple), it is returned as is.
If given nil
, it will return an empty filter (:eldap.and([])
).
Examples:
iex> Paddle.Filters.construct_filter(uid: "testuser")
{:equalityMatch, {:AttributeValueAssertion, 'uid', 'testuser'}}
iex> Paddle.Filters.construct_filter(%{uid: "testuser"})
{:equalityMatch, {:AttributeValueAssertion, 'uid', 'testuser'}}
iex> Paddle.Filters.construct_filter(%{"uid" => "testuser"})
{:equalityMatch, {:AttributeValueAssertion, 'uid', 'testuser'}}
iex> Paddle.Filters.construct_filter(:eldap.substrings('uid', initial: 'b'))
{:substrings, {:SubstringFilter, 'uid', [initial: 'b']}}
iex> Paddle.Filters.construct_filter(nil)
{:and, []}
iex> Paddle.Filters.construct_filter([])
{:and, []}
iex> Paddle.Filters.construct_filter(uid: "testuser", cn: "Test User")
{:and,
[equalityMatch: {:AttributeValueAssertion, 'uid', 'testuser'},
equalityMatch: {:AttributeValueAssertion, 'cn', 'Test User'}]}
Merge two filters with an “and” operation.
Examples:
iex> Paddle.Filters.merge_filter([uid: "testuser"], [cn: "Test User"])
{:and,
[equalityMatch: {:AttributeValueAssertion, 'uid', 'testuser'},
equalityMatch: {:AttributeValueAssertion, 'cn', 'Test User'}]}
iex> Paddle.Filters.merge_filter([uid: "testuser"], :eldap.substrings('cn', [initial: 'Tes']))
{:and,
[equalityMatch: {:AttributeValueAssertion, 'uid', 'testuser'},
substrings: {:SubstringFilter, 'cn', [initial: 'Tes']}]}
iex> Paddle.Filters.merge_filter([uid: "testuser"], [])
[uid: "testuser"]
iex> Paddle.Filters.merge_filter([], [cn: "Test User"])
[cn: "Test User"]
iex> Paddle.Filters.merge_filter([], nil)
{:and, []}