[Ruby-activeldap-discuss] How do I list the values of all attributes?

Matt Mencel MR-Mencel at wiu.edu
Fri Nov 30 13:01:40 EST 2007


Here's the bind results.  Doesn't look like it is trying to search for any user or return any attributes.  Do I need to do a search to pull the LDAP data into the User object?

[30/Nov/2007:11:54:50 -0600] conn=132533286 op=-1 msgId=-1 - fd=259 slot=259 LDAP connection from xxx to xxx
[30/Nov/2007:11:54:50 -0600] conn=132533286 op=0 msgId=1 - BIND dn="cn=...dc=edu" method=128 version=3
[30/Nov/2007:11:54:50 -0600] conn=132533286 op=0 msgId=1 - RESULT err=0 tag=97 nentries=0 etime=0 dn="cn=...dc=edu"
[30/Nov/2007:11:54:50 -0600] conn=132533286 op=1 msgId=2 - SRCH base="" scope=0 filter="(objectClass=*)" attrs="subschemaSubentry"
[30/Nov/2007:11:54:50 -0600] conn=132533286 op=1 msgId=2 - RESULT err=0 tag=101 nentries=1 etime=0
[30/Nov/2007:11:54:50 -0600] conn=132533286 op=2 msgId=3 - SRCH base="cn=schema" scope=0 filter="(objectClass=subschema)" attrs="objectClasses attributeTypes matchingRules matchingRuleUse dITStructureRules dITContentRules nameForms ldapSyntaxes"
[30/Nov/2007:11:54:51 -0600] conn=132533286 op=2 msgId=3 - RESULT err=0 tag=101 nentries=1 etime=1
[30/Nov/2007:11:54:51 -0600] conn=132533286 op=3 msgId=4 - UNBIND
[30/Nov/2007:11:54:51 -0600] conn=132533286 op=3 msgId=-1 - closing - U1
[30/Nov/2007:11:54:51 -0600] conn=132533286 op=-1 msgId=-1 - closed.

>>>>>MY CODE
require 'rubygems'
require 'active_ldap'

class User < ActiveLdap::Base
  ldap_mapping :dn_attribute => 'uid', :prefix => 'ou=People', :classes => ['person','top']
end

print "What's your username: "
user = gets.strip

puts "\nHere's your LDAP record:\n\n----"

ActiveLdap::Base.establish_connection(:host => 'ldap.mydom.com',
                         :port => 389,
                         :base => 'dc=mydom,dc=com',
                         :bind_dn => 'cn=ldapbrowser,ou=applications,dc=mydom,dc=com',
                         :password_block => Proc.new { 'password' } )

user = User.new(user)
user.attribute_names.each do |name|
  puts "#{name}: #{user[name, true].join(', ')}"
end
<<<<<

Thanks,
Matt


----- Original Message -----
From: "Kouhei Sutou" <kou at cozmixng.org>
To: ruby-activeldap-discuss at rubyforge.org
Sent: Friday, November 30, 2007 7:55:10 AM (GMT-0600) America/Chicago
Subject: Re: [Ruby-activeldap-discuss] How do I list the values of all attributes?

Hi,

In <1659960306.3126681196364695982.JavaMail.root at zcs5.wiu.edu>
  "[Ruby-activeldap-discuss] How do I list the values of all attributes?" on Thu, 29 Nov 2007 13:31:35 -0600 (CST),
  Matt Mencel <MR-Mencel at wiu.edu> wrote:


> How do I get a list of all the attributes WITH their values?

There are no convenience way. You need to like the
following:

  user.attribute_names.each do |name|
    puts "#{name}: #{user[name, true].join(', ')}"
  end

Should #attributes return all available attributes not just
set attributes?


Thanks,
--
kou
_______________________________________________
Ruby-activeldap-discuss mailing list
Ruby-activeldap-discuss at rubyforge.org
http://rubyforge.org/mailman/listinfo/ruby-activeldap-discuss



More information about the Ruby-activeldap-discuss mailing list