Created
November 9, 2015 19:30
-
-
Save jeffweiss/5e0e3c7a3e3a9983b847 to your computer and use it in GitHub Desktop.
sample of using eldap from elixir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: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) | |
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
Thanks, this gist was very helpful to me