SYNRC LDAP

MIX
RUN
$ mix deps.get
$ iex -S mix
Erlang/OTP 24 [erts-12.2.1] [source] [64-bit]
[smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Interactive Elixir (1.12.2) - press Ctrl+C to exit (type h() ENTER for help)
> :application.which_applications
[
{:ldap, 'LDAP Directory and Identity Server', '8.6.0'},
{:eldap, 'Ldap api', '1.2.9'},
{:mix, 'mix', '1.12.2'},
{:iex, 'iex', '1.12.2'},
{:elixir, 'elixir', '1.12.2'},
{:compiler, 'ERTS CXC 138 10', '8.0.4'},
{:stdlib, 'ERTS CXC 138 10', '3.17'},
{:kernel, 'ERTS CXC 138 10', '8.2'}
]
CODE
def testConnection() do
# {:ok, conn} = :eldap.open(['127.0.0.1'], [{:port, 389}, {:ssl, false}])
{:ok, conn} = :eldap.open(['127.0.0.1'], [{:port, 636}, {:ssl, true}])
:eldap.start_tls(conn, [])
:ok = :eldap.simple_bind(conn, 'cn=admin,dc=synrc,dc=com', 'secret')
filter = {:filter, :eldap.and([ ])}
scope = {:scope, :wholeSubtree}
base = {:base, 'dc=synrc,dc=com'}
attrs = {:attributes, ['cn','mail']}
{:ok, x} = :eldap.search(conn, [base, scope, filter, attrs])
:lists.map(fn {:eldap_entry, dn, attrs} ->
{:dn,dn,attrs} end, :erlang.element(2, x))
end
TEST
> LDAP.testConnection
[
{:dn, 'cn=Maxim Sokhatsky,ou=People,dc=synrc,dc=com',
[{'mail', ['[email protected]']}, {'cn', ['Maxim Sokhatsky']}]},
{:dn, 'cn=Namdak Tonpa,ou=People,dc=synrc,dc=com',
[{'mail', ['[email protected]']}, {'cn', ['Namdak Tonpa']}]},
{:dn, 'uid=admin,dc=synrc,dc=com', []},
{:dn, 'ou=People,dc=synrc,dc=com', []},
{:dn, 'dc=synrc,dc=com', []}
]