Take other eldap_search_result cases into account
Reported here https://github.com/rabbitmq/rabbitmq-server/discussions/4281#discussioncomment-2508220 Fixes #4444 Follow-up to #4285
This commit is contained in:
parent
e73b52ee6a
commit
8d8847e069
|
@ -352,9 +352,15 @@ search_groups(LDAP, Desc, GroupsBase, Scope, DN) ->
|
|||
[];
|
||||
{ok, {referral, Referrals}} ->
|
||||
{error, {referrals_not_supported, Referrals}};
|
||||
{ok, #eldap_search_result{entries = []}} ->
|
||||
%% support #eldap_search_result before and after
|
||||
%% https://github.com/erlang/otp/pull/5538
|
||||
{ok, {eldap_search_result, [], _Referrals}} ->
|
||||
[];
|
||||
{ok, #eldap_search_result{entries = Entries}} ->
|
||||
{ok, {eldap_search_result, [], _Referrals, _Controls}}->
|
||||
[];
|
||||
{ok, {eldap_search_result, Entries, _Referrals}} ->
|
||||
[ON || #eldap_entry{object_name = ON} <- Entries];
|
||||
{ok, {eldap_search_result, Entries, _Referrals, _Controls}} ->
|
||||
[ON || #eldap_entry{object_name = ON} <- Entries]
|
||||
end.
|
||||
|
||||
|
@ -438,7 +444,11 @@ object_exists(DN, Filter, LDAP) ->
|
|||
{scope, eldap:baseObject()}]) of
|
||||
{ok, {referral, Referrals}} ->
|
||||
{error, {referrals_not_supported, Referrals}};
|
||||
{ok, #eldap_search_result{entries = Entries}} ->
|
||||
%% support #eldap_search_result before and after
|
||||
%% https://github.com/erlang/otp/pull/5538
|
||||
{ok, {eldap_search_result, Entries, _Referrals}} ->
|
||||
length(Entries) > 0;
|
||||
{ok, {eldap_search_result, Entries, _Referrals, _Controls}} ->
|
||||
length(Entries) > 0;
|
||||
{error, _} = E ->
|
||||
E
|
||||
|
@ -451,9 +461,15 @@ attribute(DN, AttributeName, LDAP) ->
|
|||
{attributes, [AttributeName]}]) of
|
||||
{ok, {referral, Referrals}} ->
|
||||
{error, {referrals_not_supported, Referrals}};
|
||||
{ok, #eldap_search_result{entries = E = [#eldap_entry{}|_]}} ->
|
||||
%% support #eldap_search_result before and after
|
||||
%% https://github.com/erlang/otp/pull/5538
|
||||
{ok, {eldap_search_result, E = [#eldap_entry{}|_], _Referrals}} ->
|
||||
get_attributes(AttributeName, E);
|
||||
{ok, #eldap_search_result{entries = _}} ->
|
||||
{ok, {eldap_search_result, E = [#eldap_entry{}|_], _Referrals, _Controls}} ->
|
||||
get_attributes(AttributeName, E);
|
||||
{ok, {eldap_search_result, _Entries, _Referrals}} ->
|
||||
{error, not_found};
|
||||
{ok, {eldap_search_result, _Entries, _Referrals, _Controls}} ->
|
||||
{error, not_found};
|
||||
{error, _} = E ->
|
||||
E
|
||||
|
@ -829,15 +845,19 @@ dn_lookup(Username, LDAP) ->
|
|||
{attributes, ["distinguishedName"]}]) of
|
||||
{ok, {referral, Referrals}} ->
|
||||
{error, {referrals_not_supported, Referrals}};
|
||||
%% support #eldap_search_result before and after
|
||||
%% https://github.com/erlang/otp/pull/5538
|
||||
%% support #eldap_search_result before and after
|
||||
%% https://github.com/erlang/otp/pull/5538
|
||||
{ok, {eldap_search_result, [#eldap_entry{object_name = DN}], _Referrals}}->
|
||||
?L1("DN lookup: ~s -> ~s", [Username, DN]),
|
||||
DN;
|
||||
{ok, {eldap_search_result, [#eldap_entry{object_name = DN}], _Referrals, _Controls}}->
|
||||
?L1("DN lookup: ~s -> ~s", [Username, DN]),
|
||||
DN;
|
||||
{ok, #eldap_search_result{entries = Entries}} ->
|
||||
{ok, {eldap_search_result, Entries, _Referrals}} ->
|
||||
rabbit_log_ldap:warning("Searching for DN for ~s, got back ~p",
|
||||
[Filled, Entries]),
|
||||
Filled;
|
||||
{ok, {eldap_search_result, Entries, _Referrals, _Controls}} ->
|
||||
rabbit_log_ldap:warning("Searching for DN for ~s, got back ~p",
|
||||
[Filled, Entries]),
|
||||
Filled;
|
||||
|
|
Loading…
Reference in New Issue