Exldap Update v0.1.0 Exldap.Update

A module for adding / updating information in LDAP from Elixir via Exldap

Link to this section Summary

Functions

Add an entry. The entry must not exist. Attributes can be supplied either as a map or a keyword list, with either atoms or strings as keys.

Delete an entry.

Modify an entry.

Link to this section Types

Link to this type

distinguished_name()

distinguished_name() :: String.t()
Link to this type

mod_op_name()

mod_op_name() :: :add | :delete | :replace
Link to this type

modify_op()

modify_op() :: term()
Link to this type

return_value()

return_value() :: :ok | {:ok, {:referral, [String.t()]}} | {:error, term()}

Link to this section Functions

Link to this function

add(connection, dn, attrs)

add(pid(), distinguished_name(), map() | [keyword()]) :: return_value()

Add an entry. The entry must not exist. Attributes can be supplied either as a map or a keyword list, with either atoms or strings as keys.

Examples:

iex> Exldap.Update.add(
...>   connection,
...>   "CN=someUser,OU=Accounts,DC=example,DC=com",
...>   %{objectClass: ["person", "top"], sn: "User", cn: "someUser"}
...> )
:ok


iex> Exldap.Update.add(
...>   connection,
...>   "CN=someUser,OU=Accounts,DC=example,DC=com",
...>   [{"objectClass", "top"}, objectClass: "person", sn: "User", cn: "someUser"]
...> )
:ok
Link to this function

delete(connection, dn)

delete(pid(), distinguished_name()) :: return_value()

Delete an entry.

Example:

iex> Exldap.Update.delete(connection, "CN=someUser,OU=Accounts,DC=example,DC=com")
:ok
iex> Exldap.Update.delete(connection, "CN=someUser,OU=Accounts,DC=example,DC=com")
{:error, :noSuchObject}
Link to this function

mod_add(type, values)

mod_add(term(), term() | [term()]) :: modify_op()
Link to this function

mod_delete(type, values)

mod_delete(term(), term() | [term()]) :: modify_op()
Link to this function

mod_replace(type, values)

mod_replace(term(), term() | [term()]) :: modify_op()
Link to this function

modify(connection, dn, ops)

Modify an entry.

Examples:

# Single modification
iex> Exldap.Update.modify(
...>   connection,
...>   "CN=someUser,OU=Accounts,DC=example,DC=com",
...>   Exldap.Update.mod_add("displayName", "Some User")
...> )
:ok

# Multiple modifications
iex> Exldap.Update.modify(
...>   connection,
...>   "CN=someUser,OU=Accounts,DC=example,DC=com",
...>   [
...>     Exldap.Update.mod_add("mail", ["someuser@example.com", "some.user@example.com"]),
...>     Exldap.Update.mod_delete("displayName", "Some User")
...>   ]
...> )
:ok

# Flat form
iex> Exldap.Update.modify(
...>   connection,
...>   "CN=someUser,OU=Accounts,DC=example,DC=com",
...>   {:add, :displayName, "Some User"}
...> )
:ok

iex> Exldap.Update.modify(
...>   connection,
...>   "CN=someUser,OU=Accounts,DC=example,DC=com",
...>   [
...>     {:add, :mail, ["someuser@example.com", "some.user@example.com"]},
...>     {:delete, :displayName, "Some User"}
...>   ]
...> )
:ok