# Please help

**URL:** <https://www.ruby-forum.com/t/please-help/131558>\
**Category:** Ruby\
**Created:** [March 11, 2008, 11:34am UTC](https://www.ruby-forum.com/t/please-help/131558 "2008-03-11T11:34:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lokesh\_name](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8c91f0/32.png) [@lokesh\_name](https://www.ruby-forum.com/u/lokesh_name)\
**Post date:** [March 11, 2008, 11:34am UTC](https://www.ruby-forum.com/t/please-help/131558/1 "2008-03-11T11:34:27Z")

</div>

Hi All,

I have written a scipt.

require ‘rubygems’  
require ‘net/ldap’  
require “env\_variable.rb”

ldap = Net::LDAP.new :host =\> ‘10.44.169.24’,  
:port =\> 389,  
:auth =\> {  
:method =\> :simple,  
:username =\> “cn=Manager,dc=ibm,dc=com”,  
:password =\> “secret”  
}

filter = Net::LDAP::Filter.eq( “mail”, $email )  
treebase = “dc=ibm,dc=com”  
attrs = [“status”]  
ldap.search( :base =\> treebase, :filter =\> filter, :attributes =\>  
attrs ) do |entry|  
entry.each do |attribute, values|  
$i = 1  
values.each do |$status|  
end  
puts $status  
end  
end

and I am getting output  
Inactive  
mail=$email,ou=people,o=external,dc=ibm,dc=com

means $status variable is holding text Inactive first time and second  
time its value is  
mail=$email,ou=people,o=external,dc=ibm,dc=com (first value get  
replaced by new value)

I want to take both the values in variable or in array.

Can anyone help me please.

Thanks and Regards  
Lokesh Agrawal

---

<div class="post-metadata">

**Author:** ![lokesh\_name](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/8c91f0/32.png) [@lokesh\_name](https://www.ruby-forum.com/u/lokesh_name)\
**Post date:** [March 11, 2008, 6:16pm UTC](https://www.ruby-forum.com/t/please-help/131558/2 "2008-03-11T18:16:12Z")

</div>

On Tue, Mar 11, 2008 at 5:35 AM, Lokesh Agrawal  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ldap = Net::LDAP.new :host =\> ‘10.44.169.24’,  
> attrs = [“status”]  
> ldap.search( :base =\> treebase, :filter =\> filter, :attributes =\>  
> attrs ) do |entry|  
> entry.each do |attribute, values|  
> $i = 1

It is not clear what the purpose of $i is here.

> ```
> values.each do |$status|
> end
> 
> ```

I’m assuming that end was unintended/misplaced.

> means $status variable is holding text Inactive first time and second  
> time its value is  
> mail=$email,ou=people,o=external,dc=ibm,dc=com (first value get  
> replaced by new value)
> 
> I want to take both the values in variable or in array.

I haven’t used ldap, but maybe something similar to this might work…

a = [1,2,3]  
b = [] #initialize before block  
a.each {|i| b \<\< a} #append  
p b

Todd
