Retain the try do so an LDAP failure can fall back to local database.
This fixes tests but the automatic fallback may not be well documented behavior.
This commit is contained in:
parent
af3bf8a462
commit
91d1d7260b
1 changed files with 23 additions and 19 deletions
|
@ -65,30 +65,34 @@ defp ldap_user(name, password) do
|
|||
|
||||
case :eldap.open([to_charlist(host)], options) do
|
||||
{:ok, connection} ->
|
||||
cond do
|
||||
ssl ->
|
||||
:application.ensure_all_started(:ssl)
|
||||
try do
|
||||
cond do
|
||||
ssl ->
|
||||
:application.ensure_all_started(:ssl)
|
||||
|
||||
tls ->
|
||||
case :eldap.start_tls(
|
||||
connection,
|
||||
tlsopts,
|
||||
@connection_timeout
|
||||
) do
|
||||
:ok ->
|
||||
:ok
|
||||
tls ->
|
||||
case :eldap.start_tls(
|
||||
connection,
|
||||
tlsopts,
|
||||
@connection_timeout
|
||||
) do
|
||||
:ok ->
|
||||
:ok
|
||||
|
||||
error ->
|
||||
Logger.error("Could not start TLS: #{inspect(error)}")
|
||||
:eldap.close(connection)
|
||||
end
|
||||
error ->
|
||||
Logger.error("Could not start TLS: #{inspect(error)}")
|
||||
:eldap.close(connection)
|
||||
end
|
||||
|
||||
true ->
|
||||
:ok
|
||||
true ->
|
||||
:ok
|
||||
end
|
||||
|
||||
bind_user(connection, ldap, name, password)
|
||||
after
|
||||
:eldap.close(connection)
|
||||
end
|
||||
|
||||
bind_user(connection, ldap, name, password)
|
||||
|
||||
{:error, error} ->
|
||||
Logger.error("Could not open LDAP connection: #{inspect(error)}")
|
||||
{:error, {:ldap_connection_error, error}}
|
||||
|
|
Loading…
Reference in a new issue