From: Ollivier Robert Date: 2001-03-01T18:10:05+09:00 Subject: [ruby-talk:11837] LDAP module problem I'm a beginner in ruby (what a great language!) and I'm trying to convert my Perl scripts. I have one using the Net::LDAP module so I tool the ruby-ldap module. 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... Thanks. bind: Success ldap2mutt.rb:49:in `get_values': # is not valid entry (LDAP::InvalidEntryError) from ldap2mutt.rb:49 from ldap2mutt.rb:48:in `each' from ldap2mutt.rb:48 from ldap2mutt.rb:32:in `bind' from ldap2mutt.rb:32 the script: -=-=- #! /usr/bin/env ruby # -*-Ruby-*- # ## Copyright 2001 Ollivier Robert # ## Gets the list of mail recipients from the LDAP server and generates ## a mutt compatible alias file. ## # ## 1.0 28/02/2001 first version # require 'ldap' ## Config. ldap_base = "ou=EEC, o=EUROCONTROL" ldap_filter = "(&(objectclass=inetOrgPerson)(objectclass=mailRecipient))" ldap_attrs = [ "sn", "givenname", "telephonenumber", "roomnumber", "mail", "uid", "ou", ] ldap_server = "ldap.eurocontrol.fr" users = Hash.new conn = LDAP::Conn.new (ldap_server, LDAP::LDAP_PORT) conn.bind { conn.perror ("bind") begin conn.search (ldap_base, LDAP::LDAP_SCOPE_SUBTREE, ldap_filter, ldap_attrs) { |e| users[e.vals("uid").to_s] = e; } rescue LDAP::ResultError => msg $stderr.print (msg) end uids = Array.new uids = users.keys uids.sort.each { |key| print "#{key} = #{users[key].vals('cn')}\n" } } -=-=- -- Ollivier ROBERT -=- Eurocontrol EEC/ITM -=- roberto@eurocontrol.fr Usenet Canal Historique FreeBSD: The Power to Serve!