# Net::LDAP and telephonenumber attribute

**URL:** <https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830>\
**Category:** Ruby\
**Created:** [June 26, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830 "2007-06-26T17:06:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pearly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f8ce5/32.png) [@pearly](https://www.ruby-forum.com/u/pearly)\
**Post date:** [June 26, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830/1 "2007-06-26T17:06:45Z")

</div>

Hi,

Using the LDAP service of a Lotus Notes / Domino server, I cannot  
get the telephone attribute for people. Sad it is but Lotus like M$  
call it telephonenumber. I use ‘net/ldap’ for this which works fine  
for  
other attributes. Net::LDAP#search delivers an Array of  
Net::LDAP::Entry objects, and I can call attributes like the  
following simplified example shows:

ldap.search( :base =\> base, :filter =\> ldap\_filter ) do |entry|  
puts “DN: #{entry.dn} Name: #{entry.givenname} #{entry.sn}”  
end

Now, it looks like the telephonenumber attribute is not delivered.  
Having done a simillar application in Perl (using Net::LDAP) which  
still works with the same LDAP server and parameters, I know the  
attribute should be there. But the following results in a  
NoMethodError exception.

ldap.search( :base =\> base, :filter =\> ldap\_filter ) do |entry|  
puts “Phone: #{entry.telephonenumber}”  
end

Using entry.telephone doesn’t help, and adding the attribute  
list to the Net::LDAP#search (e.g. [:dn, :sn, :telephonenumber])  
doesn’t help.

Btw: In the above code block I tried entry.methods.sort  
and was really surprised it did not show things like ‘dn’ or  
‘mail’ as its methods; however they are working.

Any idea how to get this telephonenumber attribute?

MP

---

<div class="post-metadata">

**Author:** ![pearly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f8ce5/32.png) [@pearly](https://www.ruby-forum.com/u/pearly)\
**Post date:** [June 27, 2007, 6:24pm UTC](https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830/2 "2007-06-27T18:24:26Z")

</div>

On 6/26/07, pearly [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ldap.search( :base =\> base, :filter =\> ldap\_filter ) do |entry|
> 
> Any idea how to get this telephonenumber attribute?
> 
> MP

What happens if you use Net::LDAP::Entry#each to dump out all of the  
attributes that were returned from the server?

---

<div class="post-metadata">

**Author:** ![pearly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f8ce5/32.png) [@pearly](https://www.ruby-forum.com/u/pearly)\
**Post date:** [July 17, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830/3 "2007-07-17T18:21:44Z")

</div>

Hi. Strange: Looks like somebody posted a reply  
which I could not see - neither in the news reader  
nor in [groups.google.com](http://groups.google.com).  
The sender’s ID was ‘garbagecat10’.  
I found the reply when giving it another trial  
under “Forbiddenweb Archive”. Anybody any idea  
what happened there?

Ok, here is the contributor’s question back to me,  
so he/her or anybody else may have further ideas:

> What happens if you use Net::LDAP::Entry#each to dump  
> out all of the attributes that were returned from the  
> server?

This results in the following list:

roaminguser  
mailsystem  
sn  
checkpassword  
cn  
messagestorage  
passwordchangeinterval  
displayname  
encryptincomingmail  
uid  
passwordgraceperiod  
originalmodtime  
roamcleansetting  
givenname  
objectclass  
roamcleanper  
mail  
maildomain  
personaltitle  
availablefordirsync  
dn

So no telephonenumber, no telephone.

Any further ideas?  
Thanks to all of you.  
MP

---

<div class="post-metadata">

**Author:** ![pearly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f8ce5/32.png) [@pearly](https://www.ruby-forum.com/u/pearly)\
**Post date:** [July 17, 2007, 7:18pm UTC](https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830/4 "2007-07-17T19:18:52Z")

</div>

On 7/17/07, pearly [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> checkpassword  
> objectclass  
> roamcleanper  
> mail  
> maildomain  
> personaltitle  
> availablefordirsync  
> dn
> 
> So no telephonenumber, no telephone.

Ok, that’s really weird. Did you try setting the attributes parameter to  
Net::LDAP#search? If that doesn’t work, then please try something like  
ldapsearch and verify that the attribute really is returned. (I know you  
said Net::LDAP in perl worked, but I’d like a little more confirmation.)

If that fails, then it could be a bug in Net::LDAP and I’ll want to  
follow  
up with you offlist to track it down.

---

<div class="post-metadata">

**Author:** ![pearly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f8ce5/32.png) [@pearly](https://www.ruby-forum.com/u/pearly)\
**Post date:** [July 20, 2007, 8:07pm UTC](https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830/5 "2007-07-20T20:07:54Z")

</div>

If you have access to the LDAP server admin, you might want to ask if  
there is a filter preventing anonymous binds from revealing the  
telephone  
attribute.

Your code seems to imply that your are doing anonymous binds.

---

<div class="post-metadata">

**Author:** ![pearly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/5f8ce5/32.png) [@pearly](https://www.ruby-forum.com/u/pearly)\
**Post date:** [July 20, 2007, 4:20am UTC](https://www.ruby-forum.com/t/net-ldap-and-telephonenumber-attribute/107830/6 "2007-07-20T04:20:33Z")

</div>

On Jul 17, 8:15 am, pearly [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> cn  
> roamcleanper  
> MP  
> The first thing that jumps to my mind is rights…have you tried this  
> code as the “manager”?

Anyway to turn logging way up on the server side so you can compare  
the requests that work against those that don’t?

Mike B.
