Skip to content

Instantly share code, notes, and snippets.

@jeffweiss
Created November 9, 2015 19:30
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffweiss/5e0e3c7a3e3a9983b847 to your computer and use it in GitHub Desktop.
Save jeffweiss/5e0e3c7a3e3a9983b847 to your computer and use it in GitHub Desktop.
sample of using eldap from elixir
:application.ensure_all_started(:ssl)
{:ok, handle} = :eldap.open(['ldap.example.com'], [{:port, 636}, {:ssl, true}])
authenticated =
:ok == :eldap.simple_bind(handle,
'uid=jeff,ou=users,dc=example,dc=com',
'notmyrealpassword')
{:ok, {:eldap_search_result, list_of_entries, _}} =
:eldap.search(handle, [
{:base, 'ou=users,dc=example,dc=com'},
{:filter, :eldap.equalityMatch('sn', 'Weiss')}
])
:eldap.close(handle)
@rawsyntax
Copy link

Thanks, this gist was very helpful to me

@jsonkenl
Copy link

Thanks, this was helpful to me also. FYI, if you're using Active Directory you need to swap 'uid' with 'cn' (at least that's how ours is set up).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment