# Re: Net::LDAP 0.0.4 released

**URL:** <https://www.ruby-forum.com/t/re-net-ldap-0-0-4-released/65059>\
**Category:** Ruby\
**Created:** [August 15, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/re-net-ldap-0-0-4-released/65059 "2006-08-15T22:42:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [August 15, 2006, 10:42pm UTC](https://www.ruby-forum.com/t/re-net-ldap-0-0-4-released/65059/1 "2006-08-15T22:42:50Z")

</div>

> > I do two things with ldap - validation (does the user exist?) and
> 
> don’t have any directories that permit one. So you could try  
> )
> 
> if rs
> 
> # you’re in
> 
> else
> 
> # you’re not
> 
> end
> 
> Does this work for you?

Works perfectly, thanks! I removed the parens from the filter, however.  
My experience has showed me that not all platforms liked the parens and  
it works fine without them (at least it does here at work).

Now, what would be the best way to test for the mere presence of a user  
record, i.e. no password?

Regards,

Dan

This communication is the property of Qwest and may contain confidential  
or  
privileged information. Unauthorized use of this communication is  
strictly  
prohibited and may be unlawful. If you have received this communication  
in error, please immediately notify the sender by reply e-mail and  
destroy  
all copies of the communication and any attachments.

---

<div class="post-metadata">

**Author:** ![BergerS\_Daniel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bc8723/32.png) [@BergerS\_Daniel](https://www.ruby-forum.com/u/BergerS_Daniel)\
**Post date:** [August 15, 2006, 10:54pm UTC](https://www.ruby-forum.com/t/re-net-ldap-0-0-4-released/65059/2 "2006-08-15T22:54:51Z")

</div>

On 8/15/06, Berger, Daniel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > On 8/15/06, Berger, Daniel [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> Works perfectly, thanks! I removed the parens from the filter, however.  
> My experience has showed me that not all platforms liked the parens and  
> it works fine without them (at least it does here at work).
> 
> Now, what would be the best way to test for the mere presence of a user  
> record, i.e. no password?

I noticed you had given your original code sample without parens around  
the  
filter. Out of curiosity, what kind of LDAP server are you connecting  
to?  
Searching for a user without binding ought to be easy:

require ‘net/ldap’

ldap = Net::LDAP.new  
ldap.host = “[ldap.foo.com](http://ldap.foo.com)”  
ldap.base = “ou=People,[o=foo.com](http://o=foo.com)”

rs = ldap.search( :filter =\> “uid=djberge”)

if rs  
puts “DN: #{rs.first.dn}”  
end

By the way, you don’t have to instantiate a Net::LDAP object every time  
you  
need to hit the server. Just instantiate it once and keep it around in a  
singleton or global.
