paddle v0.1.1 Paddle.Parsing
Module used to parse dn and other LDAP related stuffs.
Summary
Functions
Get a binary map representation of several eldap entries
Get a binary map representation of a single eldap entry
Construct a DN Erlang string based on a keyword list or a string
Tranform an LDAP DN to a keyword list
Escape special LDAP characters in a string
Wrap things in lists and convert binaries / atoms to charlists
Convert a user-friendly modify operation to an eldap operation
Functions
Get a binary map representation of several eldap entries.
Example:
iex> Paddle.Parsing.clean_entries([{:eldap_entry, 'uid=testuser,ou=People', [{'uid', ['testuser']}]}])
[%{"dn" => "uid=testuser,ou=People", "uid" => ["testuser"]}]
Get a binary map representation of a single eldap entry.
Example:
iex> Paddle.Parsing.clean_entry({:eldap_entry, 'uid=testuser,ou=People', [{'uid', ['testuser']}]})
%{"dn" => "uid=testuser,ou=People", "uid" => ["testuser"]}
construct_dn(keyword | [{binary, binary}], binary | charlist) :: charlist
Construct a DN Erlang string based on a keyword list or a string.
Examples:
iex> Paddle.Parsing.construct_dn(uid: "user", ou: "People")
'uid=user,ou=People'
iex> Paddle.Parsing.construct_dn([{"uid", "user"}, {"ou", "People"}], "dc=organisation,dc=org")
'uid=user,ou=People,dc=organisation,dc=org'
iex> Paddle.Parsing.construct_dn("uid=user,ou=People", "dc=organisation,dc=org")
'uid=user,ou=People,dc=organisation,dc=org'
Values are escaped.
Note: using a map is highly discouraged because the key / values may be
reordered and because they can be mistaken for a class object (see
Paddle.Class
).
Tranform an LDAP DN to a keyword list.
Well, not exactly a keyword list but a list like this:
[{"uid", "user"}, {"ou", "People"}, {"dc", "organisation"}, {"dc", "org"}]
Example:
iex> Paddle.Parsing.dn_to_kwlist("uid=user,ou=People,dc=organisation,dc=org")
[{"uid", "user"}, {"ou", "People"}, {"dc", "organisation"}, {"dc", "org"}]
Escape special LDAP characters in a string.
Example:
iex> Paddle.Parsing.ldap_escape("a=b#c\\")
'a\\=b\\#c\\\\'
Wrap things in lists and convert binaries / atoms to charlists.
iex> Paddle.Parsing.list_wrap "hello"
['hello']
iex> Paddle.Parsing.list_wrap :hello
['hello']
iex> Paddle.Parsing.list_wrap ["hello", "world"]
['hello', 'world']
Convert a user-friendly modify operation to an eldap operation.
Examples:
iex> Paddle.Parsing.mod_convert {:add, {"description", "This is a description"}}
{:ModifyRequest_changes_SEQOF, :add,
{:PartialAttribute, 'description', ['This is a description']}}
iex> Paddle.Parsing.mod_convert {:delete, "description"}
{:ModifyRequest_changes_SEQOF, :delete,
{:PartialAttribute, 'description', []}}
iex> Paddle.Parsing.mod_convert {:replace, {"description", "This is a description"}}
{:ModifyRequest_changes_SEQOF, :replace,
{:PartialAttribute, 'description', ['This is a description']}}