At Thu, 1 Mar 2001 18:10:05 +0900,
Ollivier Robert <roberto / REMOVETHIS.eu.org> wrote:
> What's wrong with the following please?  Did I missed something basic?
> Everytime I try to get something from one of the LDAP::Entry object, it
> barfs...

the entry object is valid in the block of the search method.
In your script, you store the entry object 'e' into the array
'users', so 'e' is valid in this block.

>     conn.search (ldap_base, 
>                  LDAP::LDAP_SCOPE_SUBTREE, 
>                  ldap_filter,
>                  ldap_attrs) { |e|
>       users[e.vals("uid").to_s] = e;
>     }

but the following line causes the exception,
it is because the value of 'users[key]' is the entry object
which is out of the block.

> print "#{key} = #{users[key].vals('cn')}\n"

if you'd like to use values which is provided by the entry
object after, try the following example:

  conn.search (ldap_base, 
               LDAP::LDAP_SCOPE_SUBTREE, 
               ldap_filter,
               ldap_attrs) { |e|
    users[e.vals("uid").to_s] = e.vals('cn');
  }

   ...snip...

  uids.sort.each { |key| 
    print "#{key} = #{users[key]}\n"
  }

of course, I think that it is nice to use entry objects
out of the block. but I've not implemented it yet from
some reason.
-- 
Takaaki Tateishi <ttate / jaist.ac.jp>