Exldap v0.6.3 Exldap View Source

Link to this section Summary

Functions

Creates a approxMatch filter. Please refer to eldap:approxMatch

Change the password of a user in active directory, must have SSL and must have connected with rights to change passwords

Change the password of the current user in active directory, must have SSL

Shutdown a connection to the LDAP server

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

Connects to an LDAP server using arguments from a keyword list

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

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

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

Creates a greaterOrEqual filter. Please refer to eldap:greaterOrEqual

Creates a lessOrEqual filter. Please refer to eldap:lessOrEqual

Modifies an existing objects distinguished name, can be used to move users/computers

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

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

Converts a SDDL representation of a Microsoft SID into a binary 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

Link to this section Types

Link to this type connect_result() View Source
connect_result() :: {:error, term()} | {:ok, term()}

Link to this section Functions

Link to this function approxMatch(field, value) View Source

Creates a approxMatch filter. Please refer to eldap:approxMatch

Example

iex> first_name_filter = Exldap.approxMatch("givenName", "Test")
Link to this function change_password(connection, user_dn, new_password) View Source

Change the password of a user in active directory, must have SSL and must have connected with rights to change passwords

Example

iex> {:ok, connection} = Exldap.connect
iex> Exldap.change_password(connection, "CN=test123,OU=Accounts,DC=example,DC=com", "NEW_PASSWORD")
:ok --> Successfully changed password
Or
{:error, error_messsage} --> Failed to changed password
Link to this function change_password(connection, user_dn, old_password, new_password) View Source

Change the password of the current user in active directory, must have SSL

Example

iex> {:ok, connection} = Exldap.connect
iex> Exldap.change_password(connection, "CN=test123,OU=Accounts,DC=example,DC=com", "OLD_PASSWORD", "NEW_PASSWORD")
:ok --> Successfully changed password
Or
{:error, error_messsage} --> Failed to changed password

Shutdown a connection to the LDAP server

Example

iex> {:ok, connection} = Exldap.connect
iex> Exldap.close(connection)
Link to this function connect(timeout \\ 3000) View Source
connect(timeout()) :: connect_result()

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

Example

iex> Exldap.connect(timeout \\ :infinity)
{:ok, connection}
Or
{:error, error_description}
Link to this function connect(args, timeout) View Source
connect(Keyword.t(), timeout()) :: connect_result()

Connects to an LDAP server using arguments from a keyword list.

Required:

  • :server
  • :port
  • :user_dn
  • :password

Optional:

  • :ssl (defaults to false)
Link to this function connect(server, port, ssl, user_dn, password, timeout \\ :infinity, sslopts \\ []) View Source
connect(
  server :: String.t(),
  port :: pos_integer(),
  ssl :: boolean(),
  user_dn :: String.t(),
  password :: String.t(),
  timeout :: timeout(),
  sslopts :: keyword()
) :: connect_result()

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)

Or

Link to this function equalityMatch(field, value) View Source

Creates a equalityMatch filter. Please refer to eldap:equalityMatch

Example

iex> name_filter = Exldap.equalityMatch("cn", "John Smith")
Link to this function extensibleMatch(match_value, match_attributes) View Source

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
Link to this function get_attribute(entry, key) View Source

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

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.get_attribute(first_result, "displayName")
{:ok, "Test User"}
OR
{:error, :attribute_does_not_exist}
Link to this function get_attribute!(entry, key) View Source

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.get_attribute!(first_result, "displayName")
"Test User"
OR
nil
Link to this function greaterOrEqual(field, value) View Source

Creates a greaterOrEqual filter. Please refer to eldap:greaterOrEqual

Example

iex> first_name_filter = Exldap.greaterOrEqual("lastLogon", "1000")
Link to this function lessOrEqual(field, value) View Source

Creates a lessOrEqual filter. Please refer to eldap:lessOrEqual

Example

iex> first_name_filter = Exldap.lessOrEqual("lastLogon", "1000")
Link to this function modify_dn(connection, dn_to_modify, new_rdn, delete_old_rdn, new_parent_ou \\ []) View Source

Modifies an existing objects distinguished name, can be used to move users/computers

Example

# The following will rename the test123 account to test456 and move from OU=Accounts,DC=example,DC=com to OU=NewAccounts,DC=example,DC=com
iex> Exldap.modify_dn(connection, "CN=test123,OU=Accounts,DC=example,DC=com", "CN=test456", true, "OU=NewAccounts,DC=example,DC=com")
:ok

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])
Link to this function open(timeout \\ :infinity) View Source

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}
Link to this function open(server, port, ssl, timeout \\ :infinity, sslopts \\ []) View Source

Open a connection to the LDAP server

Example

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

Creates a present filter. Please refer to eldap:present

Example

iex> only_users_filter = Exldap.present("objectClass")
Link to this function search(connection, options) View Source

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}
Link to this function search_attributes(entry, key) View Source

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"
OR
nil
Link to this function search_field(connection, field, name) View Source

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}
Link to this function search_field(connection, base, field, value) View Source

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}
Link to this function search_substring(connection, field, substring) View Source

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}
Link to this function search_substring(connection, base, field, substring) View Source

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}
Link to this function search_with_filter(connection, filter) View Source

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}
Link to this function search_with_filter(connection, base, filter) View Source

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}

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

Link to this function string_to_sid(sid_string) View Source

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

Link to this function substrings(field, substring) View Source

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"}])
Link to this function verify_credentials(connection, user_dn, password) View Source

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

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])

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])