Exldap v0.3.2 Exldap

Summary

Functions

Creates a approxMatch filter. Please refer to eldap:approxMatch

Shutdown a connection to the LDAP server

Connects to a LDAP server using the settings defined in config.exs

Connects to a LDAP server using the arguments passed into the function

Creates a equalityMatch filter. Please refer to eldap:equalityMatch

Creates an extensible match filter. Please refer to eldap:extensibleMatch

Creates a greaterOrEqual filter. Please refer to eldap:greaterOrEqual

Creates a lessOrEqual filter. Please refer to eldap:lessOrEqual

Allows you to negate a filter. Please refer to eldap:not

Example

Open a connection to the LDAP server using the settings defined in config.exs

Open a connection to the LDAP server

Creates a present filter. Please refer to eldap:present

Searches for a LDAP entry using the supplier connection and options list. Options list should be in the following format: [base, scope, filter, timeout]. Please refer to eldap:search

Searches for a LDAP entry and extracts an attribute based on the specified key, if the attribute does not exist returns nil

Searches for a LDAP entry, the base dn is obtained from the config.exs

Searches for a LDAP entry using the arguments passed into the function

Searches for a LDAP entry via a field using a substring, with the search base specified in config.secre.exs. For example, if you want to find all entries that have a last name that starts with “smi”, you could supply {:initial, “smi”} to the substring parameter

Searches for a LDAP entry via a field using a substring. If a string is passed to substring then the default action is {:any, substring}

Search LDAP with a raw filter function, the base to search within is obtained from config.secret.exs. Look at eldap:search for more information

Search LDAP with a raw filter function. Look at eldap:search for more information

Converts a binary representation of a Microsoft SID into SDDL notation Microsoft SID Stucture reference: http://www.selfadsi.org/deep-inside/microsoft-sid-attributes.htm

Creates a substring filter. Please refer to eldap:substrings

Verify the credentials against a LDAP connection

Allows you to combine filters in a boolean ‘and’ expression. Please refer to eldap:and

Allows you to combine filters in a boolean ‘or’ expression. Please refer to eldap:or

Functions

approxMatch(field, value)

Creates a approxMatch filter. Please refer to eldap:approxMatch

Example

iex> first_name_filter = Exldap.approxMatch("givenName", "Test")
close(connection)

Shutdown a connection to the LDAP server

Example

iex> {:ok, connection} = Exldap.connect
iex> Exldap.close(connection)
connect(timeout \\ :infinity)

Connects to a LDAP server using the settings defined in config.exs

Example

iex> Exldap.connect(timeout \\ :infinity)
{:ok, connection}
Or
{:error, error_description}
connect(server, port, ssl, user_dn, password, timeout \\ :infinity)

Connects to a LDAP server using the arguments passed into the function

Example

iex> Exldap.connect("SERVERADDRESS", 636, true, "CN=test123,OU=Accounts,DC=example,DC=com", "PASSWORD", timeout \\ :infinity)
{:ok, connection}
Or
{:error, error_description}
equalityMatch(field, value)

Creates a equalityMatch filter. Please refer to eldap:equalityMatch

Example

iex> name_filter = Exldap.equalityMatch("cn", "John Smith")
extensibleMatch(match_value, match_attributes)

Creates an extensible match filter. Please refer to eldap:extensibleMatch

Example

iex> exclude_disabled_accounts = Exldap.extensibleMatch("2", [{:type, "userAccountControl"}, {:matchingRule, "1.2.840.113556.1.4.803"}]) |> Exldap.negate
greaterOrEqual(field, value)

Creates a greaterOrEqual filter. Please refer to eldap:greaterOrEqual

Example

iex> first_name_filter = Exldap.greaterOrEqual("lastLogon", "1000")
lessOrEqual(field, value)

Creates a lessOrEqual filter. Please refer to eldap:lessOrEqual

Example

iex> first_name_filter = Exldap.lessOrEqual("lastLogon", "1000")
negate(filter)

Allows you to negate a filter. Please refer to eldap:not

Example

iex> first_name_filter = Exldap.substrings("givenName", {:any,"Test"})
iex> last_name_filter = Exldap.substrings("sn", [{:any,"123"}])
iex> not_last_name = Exldap.negate(last_name_filter)
iex> and_filter = Exldap.with_or([first_name_filter, not_last_name])
open(timeout \\ :infinity)

Open a connection to the LDAP server using the settings defined in config.exs

Example

iex> Exldap.open(timeout \\ :infinity)
{:ok, connection}
Or
{:error, error_description}
open(server, port, ssl, timeout \\ :infinity)

Open a connection to the LDAP server

Example

iex> Exldap.open("SERVERADDRESS", 636, true, timeout \\ :infinity)
{:ok, connection}
Or
{:error, error_description}
present(type)

Creates a present filter. Please refer to eldap:present

Example

iex> only_users_filter = Exldap.present("objectClass")
search(connection, options)

Searches for a LDAP entry using the supplier connection and options list. Options list should be in the following format: [base, scope, filter, timeout]. Please refer to eldap:search

Example

iex> {:ok, connection} = Exldap.connect
iex> base_config = {:base, 'OU=Accounts,DC=example,DC=com'}
iex> scope = {:scope, :eldap.wholeSubtree()}
iex> filter = {:filter, Exldap.substrings('cn', [{:any,'userac'}])}
iex> timeout = {:timeout, 1000}
iex> Exldap.search(connection, [base_config, scope, filter, timeout])
{:ok, search_results}
search_attributes(entry, key)

Searches for a LDAP entry and extracts an attribute based on the specified key, if the attribute does not exist returns nil

Example

iex> {:ok, connection} = Exldap.connect
iex> {:ok, search_results} = Exldap.search_field(connection, "OU=Accounts,DC=example,DC=com", "cn", "useraccount")
iex> {:ok, first_result} = search_result |> Enum.fetch(0)
iex> Exldap.search_attributes(first_result, "displayName")
"Test User"
search_field(connection, field, name)

Searches for a LDAP entry, the base dn is obtained from the config.exs

Example

iex> Exldap.search_field(connection, "cn", "useraccount")
{:ok, search_results}
search_field(connection, base, field, name)

Searches for a LDAP entry using the arguments passed into the function

Example

iex> {:ok, connection} = Exldap.connect
iex> Exldap.search_field(connection, "OU=Accounts,DC=example,DC=com", "cn", "useraccount")
{:ok, search_results}
search_substring(connection, field, substring)

Searches for a LDAP entry via a field using a substring, with the search base specified in config.secre.exs. For example, if you want to find all entries that have a last name that starts with “smi”, you could supply {:initial, “smi”} to the substring parameter.

Example

iex> {:ok, connection} = Exldap.connect
iex> search_results = Exldap.search_substring(connection, "sn", {:initial, "smi"})
{:ok, search_results}
search_substring(connection, base, field, substring)

Searches for a LDAP entry via a field using a substring. If a string is passed to substring then the default action is {:any, substring}

Example

iex> {:ok, connection} = Exldap.connect
iex> search_within = "OU=Accounts,DC=example,DC=com"
iex> search_results = Exldap.search_substring(connection, search_within, "sn", "middle")
{:ok, search_results}
search_with_filter(connection, filter)

Search LDAP with a raw filter function, the base to search within is obtained from config.secret.exs. Look at eldap:search for more information

Example

iex> {:ok, connection} = Exldap.connect
iex> first_name_filter = Exldap.substrings("givenName", [{:any, "test"}])
iex> last_name_filter = Exldap.substrings("sn", [{:any, "123"}])
iex> and_filter = Exldap.with_and([first_name_filter, last_name_filter])
iex> search_results = Exldap.search_with_filter(connection, and_filter)
{:ok, search_results}
search_with_filter(connection, base, filter)

Search LDAP with a raw filter function. Look at eldap:search for more information

Example

iex> {:ok, connection} = Exldap.connect
iex> search_within = "OU=Accounts,DC=example,DC=com"
iex> filter = Exldap.substrings('cn', [{:any,'userac'}])
iex> search_results = Exldap.search_substring(connection, search_within, filter)
{:ok, search_results}
sid_to_string(sid)

Converts a binary representation of a Microsoft SID into SDDL notation Microsoft SID Stucture reference: http://www.selfadsi.org/deep-inside/microsoft-sid-attributes.htm

substrings(field, substring)

Creates a substring filter. Please refer to eldap:substrings

Example

iex> first_name_filter = Exldap.substrings("givenName", {:any,"Test"})
iex> last_name_filter = Exldap.substrings("sn", [{:any,"123"}])
verify_credentials(connection, user_dn, password)

Verify the credentials against a LDAP connection

Example

iex> {:ok, connection} = Exldap.connect
iex> Exldap.verify_credentials(connection, "CN=test123,OU=Accounts,DC=example,DC=com", "PASSWORD")
:ok --> Successfully connected
Or
{:error, :invalidCredentials} --> Failed to connect
with_and(filters)

Allows you to combine filters in a boolean ‘and’ expression. Please refer to eldap:and

Example

iex> first_name_filter = Exldap.substrings("givenName", {:any,"Test"})
iex> last_name_filter = Exldap.substrings("sn", [{:any,"123"}])
iex> and_filter = Exldap.with_and([first_name_filter, last_name_filter])
with_or(filters)

Allows you to combine filters in a boolean ‘or’ expression. Please refer to eldap:or

Example

iex> first_name_filter = Exldap.substrings("givenName", {:any,"Test"})
iex> last_name_filter = Exldap.substrings("sn", [{:any,"123"}])
iex> and_filter = Exldap.with_or([first_name_filter, last_name_filter])