Net LDAP problem (no attrs or get_attributes methods)

G

Glen Holcomb

So I am having difficulty getting the attributes for an LDAP entry. If I
check for specific attributes by name that works fine. However when I try
the following:

ldap.search:)base =3D> base, :filter =3D> address_only_filter, :return_resu=
lt =3D>
false) do |entry|
p entry.dn
p entry.attrs
puts "\n\n"
end

I get the following error:

/Library/Ruby/Gems/1.8/gems/ruby-net-ldap-0.0.4/lib/net/ldap/entry.rb:152:i=
n
'method_missing': undefined method 'attrs' (NoMethodError)

I get the same NoMethodError when I try get_attributes.

I am getting a Net::LDAP::Entry object back from the search as verified by
changing the p entry.attrs to p entry.class

Anyone else run across this?

--=20
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can=92t hear a word you=92re saying."

-Greg Graffin (Bad Religion)
 
M

Michael Linfield

ldap.search(base, scope, filter, attrs) { |entry|
p entry.dn
p entry.attrs
}

Does the above work for you?

Regards,

- Mac
 
G

Glen Holcomb

Nope, same error. I passed "*" to the attrs argument.

ldap.search(base, scope, filter, attrs) { |entry|
p entry.dn
p entry.attrs
}

Does the above work for you?

Regards,

- Mac


--=20
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can=92t hear a word you=92re saying."

-Greg Graffin (Bad Religion)
 
M

Michael Linfield

Glen said:
Nope, same error. I passed "*" to the attrs argument.

Well, attrs should be an array I believe, try initializing it as such:
attrs = []
and see what happens.

Regards,

- Mac
 
G

Glen Holcomb

Glen said:
Nope, same error. I passed "*" to the attrs argument.

Well, attrs should be an array I believe, try initializing it as such:
attrs =3D []
and see what happens.

Regards,

- Mac
The docs say string or array of strings. Tried it with :attributes =3D> []
and I get the same error. I also tried reinstalling the gem but that didn'=
t
help.

--=20
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can=92t hear a word you=92re saying."

-Greg Graffin (Bad Religion)
 
M

Michael Linfield

The docs say string or array of strings. Tried it with :attributes =>
[]
and I get the same error. I also tried reinstalling the gem but that
didn't
help.

What gem are you using? ruby-net-ldap? via require 'net/ldap'?
Might help to post more of your code so I can understand the whole
picture of things...

p entry.attrs is invalid as it isn't a method per'se... hence the
NoMethodError.
attrs is like you said a string or array of strings.

It should be used via connection.add("dc=localhost, dc=localdomain",
entry)

Regards,

- Mac
 
G

Glen Holcomb

The docs say string or array of strings. Tried it with :attributes =3D=
[]
and I get the same error. I also tried reinstalling the gem but that
didn't
help.

What gem are you using? ruby-net-ldap? via require 'net/ldap'?
Might help to post more of your code so I can understand the whole
picture of things...

p entry.attrs is invalid as it isn't a method per'se... hence the
NoMethodError.
attrs is like you said a string or array of strings.

It should be used via connection.add("dc=3Dlocalhost, dc=3Dlocaldomain",
entry)

Regards,

- Mac
Here is the code in its entirety:

require 'rubygems'
require 'net/ldap'

ldap =3D Net::LDAP.new :host =3D> , :port =3D> 389, :auth =3D> { :method =
=3D> :simple,
:username =3D> "", :password =3D> "" }

address_only_filter =3D Net::LDAP::Filter.pres("mailForwardingAddress") &
~(Net::LDAP::Filter.eq("mailDeliveryOption", "forward"))

base =3D "ou=3DPeople,o=3Dcnm.edu,o=3Dcp"

ldap.search:)base =3D> base, :scope =3D> Net::LDAP::SearchScope_WholeSubtre=
e,
:filter =3D> address_only_filter, :attributes =3D> "*") do |entry|
p entry.dn
p entry.attrs
end


I've removed the credentials and the host IP intentionally. Calling a
specific attribute on the object works just fine. It just breaks when I tr=
y
to request all of them. I figured it would be the easiest way to ensure I
only remove the attribute I'm interested in since not all records are sure
to have the same attributes.


--=20
"Hey brother Christian with your high and mighty errand, Your actions speak
so loud, I can=92t hear a word you=92re saying."

-Greg Graffin (Bad Religion)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top