Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmerriweather/exldap
A module for working with LDAP from Elixir
https://github.com/jmerriweather/exldap
active-directory elixir ldap
Last synced: 19 days ago
JSON representation
A module for working with LDAP from Elixir
- Host: GitHub
- URL: https://github.com/jmerriweather/exldap
- Owner: jmerriweather
- License: mit
- Created: 2015-11-10T02:11:45.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-09-16T11:35:53.000Z (over 3 years ago)
- Last Synced: 2025-01-16T06:11:41.098Z (26 days ago)
- Topics: active-directory, elixir, ldap
- Language: Elixir
- Homepage:
- Size: 46.9 KB
- Stars: 59
- Watchers: 3
- Forks: 18
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A module for working with LDAP from Elixir. (Miscellaneous)
- fucking-awesome-elixir - exldap - A module for working with LDAP from Elixir. (Miscellaneous)
- awesome-elixir - exldap - A module for working with LDAP from Elixir. (Miscellaneous)
README
# Exldap
A module for working with LDAP from Elixir
## Installation
The package can be installed as:
1. Add exldap to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:exldap, "~> 0.6"}]
end
```
2. Ensure exldap is started before your application:
```elixir
def application do
[applications: [:exldap]]
end
```
3. Optionally add 'config\config.secret.exs' file with:
```elixir
use Mix.Configconfig :exldap, :settings,
server: ,
base: "DC=example,DC=com",
port: 636,
ssl: true,
user_dn: ,
password: ,
search_timeout: 1000 # optionally set a search timeout in milliseconds, default is infinity
```
### Usage with configuration set in config.exs```elixir
# the default_timeout is infinity{:ok, connection} = Exldap.connect(TIMEOUT \\ default_timeout) # optionally set the maximum time in milliseconds that each server request may take
{:ok, search_results} = Exldap.search_field(connection, "cn", "test123")
{:ok, first_result} = search_results |> Enum.fetch(0)
result = Exldap.search_attributes(first_result, "displayName")
```
### Usage without configuration
```elixir
# the default_timeout is infinity{:ok, connection} = Exldap.connect("SERVERADDRESS", 636, true, "CN=test123,OU=Accounts,DC=example,DC=com", "PASSWORD", TIMEOUT \\ default_timeout)
{:ok, search_results} = Exldap.search_field(connection, "OU=Accounts,DC=example,DC=com", "cn", "useraccount")
{:ok, first_result} = search_results |> Enum.fetch(0)
result = Exldap.search_attributes(first_result, "displayName")
```
### Verify credentials with configuration set in config.exs
```elixir
# the default_timeout is infinity{:ok, connection} = Exldap.open(TIMEOUT \\ default_timeout) # optionally set the maximum time in milliseconds that each server request may take
case Exldap.verify_credentials(connection, "CN=test123,OU=Accounts,DC=example,DC=com", "PASSWORD") do
:ok -> IO.puts "Successfully connected"
_ -> IO.puts "Failed to connect"
end```
### Verify credentials without configuration
```elixir
# the default_timeout is infinity
{:ok, connection} = Exldap.open("SERVERADDRESS", 636, true, TIMEOUT \\ default_timeout)
case Exldap.verify_credentials(connection, "CN=test123,OU=Accounts,DC=example,DC=com", "PASSWORD") do
:ok -> IO.puts "Successfully connected"
_ -> IO.puts "Failed to connect"
end```
### Use SSL, validating certificates, from configuration
```elixir
use Mix.Configconfig :exldap, :settings,
server: ,
base: "DC=example,DC=com",
port: 636,
ssl: true,
sslopts: [cacertfile: 'path/to/ca.pem', verify: verify_peer]
user_dn: ,
password: ,
search_timeout: 1000
```### Use SSL, validating certificates, from configuration
```elixir
sslopts=[cacertfile: 'path/to/ca.pem', verify: verify_peer]
{:ok, connection} = Exldap.connect("SERVERADDRESS", 636, true, "CN=test123,OU=Accounts,DC=example,DC=com", "PASSWORD", timeout, sslopts)
...```