From 6446032a1b248c32c5ae89f1d362d8b0a6b09f7b Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Fri, 19 Feb 2016 13:02:33 +0100 Subject: eldap: unbindRequest --- lib/eldap/doc/src/eldap.xml | 3 ++- lib/eldap/src/eldap.erl | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/eldap/doc/src/eldap.xml b/lib/eldap/doc/src/eldap.xml index 8f4479a730..7c4b76819f 100644 --- a/lib/eldap/doc/src/eldap.xml +++ b/lib/eldap/doc/src/eldap.xml @@ -88,7 +88,8 @@ filter() See present/1, substrings/2, Handle = handle() -

Shutdown the connection.

+

Shutdown the connection after sending an unbindRequest to the server. If the connection is tls the connection + will be closed with ssl:close/1, otherwise with gen_tcp:close/1.

diff --git a/lib/eldap/src/eldap.erl b/lib/eldap/src/eldap.erl index ae47c815c9..3e3f945e63 100644 --- a/lib/eldap/src/eldap.erl +++ b/lib/eldap/src/eldap.erl @@ -531,6 +531,7 @@ loop(Cpid, Data) -> ?MODULE:loop(Cpid, NewData); {_From, close} -> + {no_reply,_NewData} = do_unbind(Data), unlink(Cpid), exit(closed); @@ -578,7 +579,6 @@ loop(Cpid, Data) -> %%% -------------------------------------------------------------------- %%% startTLS Request %%% -------------------------------------------------------------------- - do_start_tls(Data=#eldap{using_tls=true}, _, _) -> {{error,tls_already_started}, Data}; do_start_tls(Data=#eldap{fd=FD} , TlsOptions, Timeout) -> @@ -897,6 +897,24 @@ do_modify_dn_0(Data, Entry, NewRDN, DelOldRDN, NewSup) -> log2(Data, "modify DN reply = ~p~n", [Resp]), check_reply(Data#eldap{id = Id}, Resp, modDNResponse). +%%%-------------------------------------------------------------------- +%%% unbindRequest +%%%-------------------------------------------------------------------- +do_unbind(Data) -> + Req = "", + log2(Data, "unbind request = ~p (has no reply)~n", [Req]), + send_request(Data#eldap.fd, Data, Data#eldap.id, {unbindRequest, Req}), + case Data#eldap.using_tls of + true -> ssl:close(Data#eldap.fd); + false -> gen_tcp:close(Data#eldap.fd) + end, + {no_reply, Data#eldap{binddn = (#eldap{})#eldap.binddn, + passwd = (#eldap{})#eldap.passwd, + fd = (#eldap{})#eldap.fd, + using_tls = false + }}. + + %%% -------------------------------------------------------------------- %%% Send an LDAP request and receive the answer %%% -------------------------------------------------------------------- -- cgit v1.2.3