[erlang-questions] eldap:search result

Adam Rutkowski hq@REDACTED
Sun Jan 12 23:55:31 CET 2014


Hi Thomas,

In this case you should include eldap's hrl file to and use records to pattern match the results.
Matching records as tuples is considered a bad practice. 
http://www.erlang.se/doc/programming_rules.shtml#HDR23

I suggest you start with:

 -include_lib("eldap/include/eldap.hrl").

Note that you'll be dealing with a _list_ of entries. 
lists:map/2 (or list comprehension) can come in handy for further processing.

Cheers,
/A.


On Jan 12, 2014, at 9:50 PM, John R. Ashmun <john.ashmun@REDACTED> wrote:

> I offer this approach:
> 
> {ok, Result} = eldap:search(S, Search),
> eldap:close(S),
> {eldap_search_result, [{_, _, [{"status", [Status]}]}], []} = Result,
> 
> & at this point, Status =:= "available", if I have successfully balanced the brackets and braces.  You may wish also to match 'eldap_entry' in your assignment.
> 
> Regards,
> John R. Ashmun
> 
> 
> On Sun, Jan 12, 2014 at 11:41 AM, Thomas Elsgaard <thomas.elsgaard@REDACTED> wrote:
> Hi list
>  
> I am experimenting with eldap, but i am wondering on how to correctly get the result from an ldap search?
>  
> In my module, i am doing an eldap:search
>  
> -----------------
> {ok, Result} = eldap:search(S, Search),
> eldap:close(S),
> io:format("Search Result: ~p~n", [Result]).
> -----------------
>  
> And i am getting following:
>  
> -----------------
> Search Result: {eldap_search_result,
>                    [{eldap_entry,
>                         "blaa,blaaa,blaa,blaa,blaa",
>                         [{"status",["available"]}]}],
>                    []}
> ok
> -----------------
>  
> So far so good, eldap is doing it's work, but what i am really interrested in is just the content of the attribute status which is "available". How can i get the status into an variable? Do i need to get it from an record, or ?
>  
> Thomas 
>  
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
> 
> 
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20140112/bed668d5/attachment.htm>


More information about the erlang-questions mailing list