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
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
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 section Functions
Creates a approxMatch filter. Please refer to eldap:approxMatch
Example
iex> first_name_filter = Exldap.approxMatch("givenName", "Test")
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
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)
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(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)
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
Creates a equalityMatch filter. Please refer to eldap:equalityMatch
Example
iex> name_filter = Exldap.equalityMatch("cn", "John Smith")
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
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}
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
Creates a greaterOrEqual filter. Please refer to eldap:greaterOrEqual
Example
iex> first_name_filter = Exldap.greaterOrEqual("lastLogon", "1000")
Creates a lessOrEqual filter. Please refer to eldap:lessOrEqual
Example
iex> first_name_filter = Exldap.lessOrEqual("lastLogon", "1000")
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])
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 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")
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}
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
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}
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}
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}
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 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 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
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
Example
iex> first_name_filter = Exldap.substrings("givenName", {:any,"Test"})
iex> last_name_filter = Exldap.substrings("sn", [{:any,"123"}])
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])