paddle v0.1.1 Paddle.Class protocol

Protocol used to allow some objects (mainly structs) to represent an LDAP entry.

Implementing this protocol for your specific classes will enable you to manipulate LDAP entries in an easier way than using DNs (hopefully).

If the class you want to implement is simple enough, you might want to use the Paddle.Class.Helper.gen_class/2 macro.

For now, only two “classes” implementing this protocol are provided: Paddle.PosixAccount and Paddle.PosixGroup.

Summary

Functions

Return a list of attributes to be generated using the given functions

Return the parent subDN (where to add / get entries of this type)

Must return the list of classes which this “class” belongs to

Return the list of required attributes for this “class”

Return the name of the attribute used in the DN to uniquely identify entries

Types

t()
t() :: term

Functions

generators(t)
generators(Paddle.Class) :: [{atom, (Paddle.Class -> term)}]

Return a list of attributes to be generated using the given functions.

Warning: do not use functions with side effects, as this function may be called even if adding a LDAP entry fails.

Example: [uid: &Paddle.PosixAccount.get_next_uid/1]

This function must take 1 parameter which will be the current class object (useful if you have interdependent attribute values) and must return the generated value.

For example, with %Paddle.PosixGroup{uid: "myUser", ...} the function will be called like this:

Paddle.PosixAccount.get_next_uid(%Paddle.PosixAccount{uid: "myUser", ...}
location(t)
location(Paddle.Class) :: binary | keyword

Return the parent subDN (where to add / get entries of this type).

Example for users: "ou=People"

The top base (e.g. "dc=organisation,dc=org") must not be specified.

object_classes(t)
object_classes(Paddle.Class) :: [binary]

Must return the list of classes which this “class” belongs to.

For example, a posixAccount could have the following object classes: ["account", "posixAccount"]

The "top" class is not required.

required_attributes(t)
required_attributes(Paddle.Class) :: [atom]

Return the list of required attributes for this “class”

For example, for the posixAccount class, the following attributes are required:

[:uid, :cn, :uidNumber, :gidNumber, :homeDirectory]
unique_identifier(t)
unique_identifier(Paddle.Class) :: atom

Return the name of the attribute used in the DN to uniquely identify entries.

For example, the identifier for an account is :uid because an account DN is like this: "uid=testuser,ou=People,..."