View Source eldap (eldap v1.2.13)

LDAP Client

This module provides a client api to the Lightweight Directory Access Protocol (LDAP).

References:

  • RFC 4510 - RFC 4519
  • RFC 2830

The above publications can be found at IETF.

DATA TYPES

Type definitions that are used more than once in this module:

Summary

Functions

add(Handle, Dn, [Attribute]) -> return_value()

'and'([Filter]) -> filter()

approxMatch(Type, Value) -> filter()

baseObject() -> scope()

close(Handle) -> ok

delete(Handle, Dn) -> return_value()

derefAlways() -> dereference()

derefFindingBaseObj() -> dereference()

derefInSearching() -> dereference()

equalityMatch(Type, Value) -> filter()

extensibleMatch(MatchValue, OptionalAttrs) -> filter()

greaterOrEqual(Type, Value) -> filter()

info(Handle) -> connection_info()

lessOrEqual(Type, Value) -> filter()

mod_add(Type, [Value]) -> modify_op()

mod_delete(Type, [Value]) -> modify_op()

mod_replace(Type, [Value]) -> modify_op()

modify(Handle, Dn, [ModifyOp]) -> return_value()

modify_dn(Handle, Dn, NewRDN, DeleteOldRDN, NewSupDN) -> return_value()

modify_password(Handle, Dn, NewPasswd) -> return_value() | {ok, GenPasswd}

modify_password(Handle, Dn, NewPasswd, OldPasswd) -> return_value() | {ok, GenPasswd}

neverDerefAliases() -> dereference()

'not'(Filter) -> filter()

open([Host]) -> {ok, Handle} | {error, Reason}

open([Host], [Option]) -> {ok, Handle} | {error, Reason}

'or'([Filter]) -> filter()

paged_result_control(PageSize) -> {control, "1.2.840.113556.1.4.319", true, binary()}

paged_result_control(PageSize, Cookie) -> {control, "1.2.840.113556.1.4.319", true, binary()}

paged_result_cookie(SearchResult) -> binary()

present(Type) -> filter()

search(Handle, SearchOptions) -> {ok, #eldap_search_result{}}{ok,
{referral,referrals()}}{error, Reason}

Search the directory with the supplied the SearchOptions. The base and filter options must be supplied. Default values: scope is wholeSubtree/0, deref is derefAlways/0, types_only is false and timeout is 0 (meaning infinity).

simple_bind(Handle, Dn, Password) -> return_value()

singleLevel() -> scope()

start_tls(Handle, Options) -> return_value()

start_tls(Handle, Options, Timeout) -> return_value()

substrings(Type, [SubString]) -> filter()

wholeSubtree() -> scope()

Functions

Link to this function

add(Handle, Entry, Attributes)

View Source (since OTP R15B01)

add(Handle, Dn, [Attribute]) -> return_value()

Add an entry. The entry must not exist.

  add(Handle,
      "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com",
       [{"objectclass", ["person"]},
        {"cn", ["Bill Valentine"]},
        {"sn", ["Valentine"]},
        {"telephoneNumber", ["545 555 00"]}]
     )
Link to this function

'and'(ListOfFilters)

View Source (since OTP R15B01)

'and'([Filter]) -> filter()

Creates a filter where all Filter must be true.

Link to this function

approxMatch(Desc, Value)

View Source (since OTP R15B01)

approxMatch(Type, Value) -> filter()

Create a approximation match filter.

Link to this function

baseObject()

View Source (since OTP R15B01)

baseObject() -> scope()

Search baseobject only.

Link to this function

close(Handle)

View Source (since OTP R15B01)

close(Handle) -> ok

Shutdown the connection after sending an unbindRequest to the server. If the connection is tls the connection will be closed with ssl:close/1, otherwise with gen_tcp:close/1.

Link to this function

delete(Handle, Entry)

View Source (since OTP R15B01)

delete(Handle, Dn) -> return_value()

Delete an entry.

  delete(Handle, "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com")
Link to this function

derefAlways()

View Source (since OTP R15B01)

derefAlways() -> dereference()

Always dereference aliases.

Link to this function

derefFindingBaseObj()

View Source (since OTP R15B01)

derefFindingBaseObj() -> dereference()

Dereference aliases only in finding the base.

Link to this function

derefInSearching()

View Source (since OTP R15B01)

derefInSearching() -> dereference()

Dereference aliases only when searching.

Link to this function

equalityMatch(Desc, Value)

View Source (since OTP R15B01)

equalityMatch(Type, Value) -> filter()

Create a equality filter.

Link to this function

extensibleMatch(MatchValue, OptArgs)

View Source (since OTP 17.4)

extensibleMatch(MatchValue, OptionalAttrs) -> filter()

Creates an extensible match filter. For example,

  eldap:extensibleMatch("Bar", [{type,"sn"}, {matchingRule,"caseExactMatch"}]))

creates a filter which performs a caseExactMatch on the attribute sn and matches with the value "Bar". The default value of dnAttributes is false.

Link to this function

greaterOrEqual(Desc, Value)

View Source (since OTP R15B01)

greaterOrEqual(Type, Value) -> filter()

Create a greater or equal filter.

Link to this function

info(Handle)

View Source (since OTP 25.3.1)

info(Handle) -> connection_info()

Currently available information reveals the socket and the transport protocol, TCP or TLS (SSL), used by the LDAP connection.

Link to this function

lessOrEqual(Desc, Value)

View Source (since OTP R15B01)

lessOrEqual(Type, Value) -> filter()

Create a less or equal filter.

Link to this function

mod_add(Type, Values)

View Source (since OTP R15B01)

mod_add(Type, [Value]) -> modify_op()

Create an add modification operation.

Link to this function

mod_delete(Type, Values)

View Source (since OTP R15B01)

mod_delete(Type, [Value]) -> modify_op()

Create a delete modification operation.

Link to this function

mod_replace(Type, Values)

View Source (since OTP R15B01)

mod_replace(Type, [Value]) -> modify_op()

Create a replace modification operation.

Link to this function

modify(Handle, Object, Mods)

View Source (since OTP R15B01)

modify(Handle, Dn, [ModifyOp]) -> return_value()

Modify an entry.

  modify(Handle, "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com",
         [eldap:mod_replace("telephoneNumber", ["555 555 00"]),
	  eldap:mod_add("description", ["LDAP Hacker"]) ])
Link to this function

modify_dn(Handle, Entry, NewRDN, DelOldRDN, NewSup)

View Source (since OTP R15B01)

modify_dn(Handle, Dn, NewRDN, DeleteOldRDN, NewSupDN) -> return_value()

Modify the DN of an entry. DeleteOldRDN indicates whether the current RDN should be removed from the attribute list after the operation. NewSupDN is the new parent that the RDN shall be moved to. If the old parent should remain as parent, NewSupDN shall be "".

  modify_dn(Handle, "cn=Bill Valentine, ou=people, o=Example Org, dc=example, dc=com ",
            "cn=Bill Jr Valentine", true, "")
Link to this function

modify_password(Handle, Dn, NewPasswd)

View Source (since OTP 18.0)

modify_password(Handle, Dn, NewPasswd) -> return_value() | {ok, GenPasswd}

Modify the password of a user. See modify_password/4.

Link to this function

modify_password(Handle, Dn, NewPasswd, OldPasswd)

View Source (since OTP 18.0)

modify_password(Handle, Dn, NewPasswd, OldPasswd) -> return_value() | {ok, GenPasswd}

Modify the password of a user.

  • Dn. The user to modify. Should be "" if the modify request is for the user of the LDAP session.
  • NewPasswd. The new password to set. Should be "" if the server is to generate the password. In this case, the result will be {ok, GenPasswd}.
  • OldPasswd. Sometimes required by server policy for a user to change their password. If not required, use modify_password/3.
Link to this function

neverDerefAliases()

View Source (since OTP R15B01)

neverDerefAliases() -> dereference()

Never dereference aliases, treat aliases as entries.

Link to this function

'not'(Filter)

View Source (since OTP R15B01)

'not'(Filter) -> filter()

Negate a filter.

Link to this function

open(Hosts)

View Source (since OTP R15B01)

open([Host]) -> {ok, Handle} | {error, Reason}

Setup a connection to an LDAP server, the HOST's are tried in order.

Link to this function

open(Hosts, Opts)

View Source (since OTP R15B01)

open([Host], [Option]) -> {ok, Handle} | {error, Reason}

Setup a connection to an LDAP server, the HOST's are tried in order.

The log function takes three arguments, fun(Level, FormatString, [FormatArg]) end.

Timeout set the maximum time in milliseconds that each server request may take.

All TCP socket options are accepted except active, binary, deliver, list, mode and packet

Link to this function

'or'(ListOfFilters)

View Source (since OTP R15B01)

'or'([Filter]) -> filter()

Create a filter where at least one of the Filter must be true.

Link to this function

paged_result_control(PageSize)

View Source (since OTP 24.3)

paged_result_control(PageSize) -> {control, "1.2.840.113556.1.4.319", true, binary()}

Paged results is an extension to the LDAP protocol specified by RFC2696

This function creates a control with the specified page size for use in search/3, for example:

Control = eldap:paged_result_control(50),
{ok, SearchResults} = search(Handle, [{base, "dc=example, dc=com"}], [Control]),
Link to this function

paged_result_control(PageSize, Cookie)

View Source (since OTP 24.3)

paged_result_control(PageSize, Cookie) -> {control, "1.2.840.113556.1.4.319", true, binary()}

Paged results is an extension to the LDAP protocol specified by RFC2696

This function creates a control with the specified page size and cookie for use in search/3 to retrieve the next results page.

For example:

PageSize = 50,
Control1 = eldap:paged_result_control(PageSize),
{ok, SearchResults1} = search(Handle, [{base, "dc=example, dc=com"}], [Control1]),
%% retrieve the returned cookie from the search results
{ok, Cookie1} = eldap:paged_result_cookie(SearchResults1),
Control2 = eldap:paged_result_control(PageSize, Cookie1),
{ok, SearchResults2} = eldap:search(Handle, [{base, "dc=example,dc=com"}], [Control2]),
%% etc
Link to this function

paged_result_cookie/1

View Source (since OTP 24.3)

paged_result_cookie(SearchResult) -> binary()

Paged results is an extension to the LDAP protocol specified by RFC2696.

This function extracts the cookie returned from the server as a result of a paged search result.

If the returned cookie is the empty string "", then these search results represent the last in the series.

Link to this function

present(Attribute)

View Source (since OTP R15B01)

present(Type) -> filter()

Create a filter which filters on attribute type presence.

Link to this function

search(Handle, X)

View Source (since OTP R15B01)
search(Handle, SearchOptions) -> {ok, #eldap_search_result{}}{ok,
{referral,referrals()}}{error, Reason}

Search the directory with the supplied the SearchOptions. The base and filter options must be supplied. Default values: scope is wholeSubtree/0, deref is derefAlways/0, types_only is false and timeout is 0 (meaning infinity).

  Filter = eldap:substrings("cn", [{any,"V"}]),
  search(Handle, [{base, "dc=example, dc=com"}, {filter, Filter}, {attributes, ["cn"]}]),

The timeout option in the SearchOptions is for the ldap server, while the timeout in eldap:open/2 is used for each individual request in the search operation.

Link to this function

simple_bind(Handle, Dn, Passwd)

View Source (since OTP R15B01)

simple_bind(Handle, Dn, Password) -> return_value()

Authenticate the connection using simple authentication.

Link to this function

singleLevel()

View Source (since OTP R15B01)

singleLevel() -> scope()

Search the specified level only, i.e. do not recurse.

Link to this function

start_tls(Handle, TlsOptions)

View Source (since OTP R16B03)

start_tls(Handle, Options) -> return_value()

Same as start_tls(Handle, Options, infinity)

Link to this function

start_tls(Handle, TlsOptions, Timeout)

View Source (since OTP R16B03)

start_tls(Handle, Options, Timeout) -> return_value()

Upgrade the connection associated with Handle to a tls connection if possible.

The upgrade is done in two phases: first the server is asked for permission to upgrade. Second, if the request is acknowledged, the upgrade to tls is performed.

Error responses from phase one will not affect the current encryption state of the connection. Those responses are:

  • tls_already_started - The connection is already encrypted. The connection is not affected.

  • {response,ResponseFromServer} - The upgrade was refused by the LDAP server. The ResponseFromServer is an atom delivered byt the LDAP server explained in section 2.3 of rfc 2830. The connection is not affected, so it is still un-encrypted.

Errors in the second phase will however end the connection:

  • Error - Any error responded from ssl:connect/3

The Timeout parameter is for the actual tls upgrade (phase 2) while the timeout in eldap:open/2 is used for the initial negotiation about upgrade (phase 1).

Link to this function

substrings(Type, SubStr)

View Source (since OTP R15B01)

substrings(Type, [SubString]) -> filter()

Create a filter which filters on substrings.

Link to this function

wholeSubtree()

View Source (since OTP R15B01)

wholeSubtree() -> scope()

Search the entire subtree.