aboutsummaryrefslogtreecommitdiff
path: root/src/ldapsp_ldap.erl
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2021-03-08 16:25:24 +0100
committerGuido Günther <agx@sigxcpu.org>2021-03-10 11:31:20 +0100
commit0a260c365eaed222425a10311502589491e633f0 (patch)
tree4ab233d070c519490045a008d86e4dfc1edb3191 /src/ldapsp_ldap.erl
parente34f8ab27f74b14ab2959d635bd7d2682e4e7979 (diff)
ldap: Allow to pass all opts to eldap:open()
This allows to e.g. use ssl or contact servers on odd ports
Diffstat (limited to 'src/ldapsp_ldap.erl')
-rw-r--r--src/ldapsp_ldap.erl10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ldapsp_ldap.erl b/src/ldapsp_ldap.erl
index e87c6d8..48b1780 100644
--- a/src/ldapsp_ldap.erl
+++ b/src/ldapsp_ldap.erl
@@ -33,7 +33,7 @@
-define(SERVER, ?MODULE).
--record(state, {server, user, password, tls=true, tls_opts}).
+-record(state, {server, user, password, opts, tls=true, tls_opts}).
%%%===================================================================
%%% API
@@ -77,6 +77,7 @@ init(Opts) ->
tls=proplists:get_value(tls, Opts, true),
tls_opts=proplists:get_value(tls_opts, Opts,
[{verify_type, verify_peer}]),
+ opts=proplists:get_value(opts, Opts),
user=proplists:get_value(user, Opts),
password=proplists:get_value(password, Opts)}}.
@@ -159,8 +160,11 @@ code_change(_OldVsn, State, _Extra) ->
start_tls(Handle, TLSOpts)->
ok = eldap:start_tls(Handle, TLSOpts).
-connect(#state{server=Server, user=User, password=Pw, tls=TLS, tls_opts=TLSOpts}) ->
- {ok, Handle} = eldap:open([Server]),
+connect(#state{server=Server, user=User, password=Pw, opts=Opts, tls=TLS, tls_opts=TLSOpts}) ->
+ {ok, Handle} = case Opts of
+ undefined -> eldap:open([Server]);
+ _ -> eldap:open([Server], Opts)
+ end,
ok = case TLS of
true -> start_tls(Handle, TLSOpts);
_ -> ok