[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Please help

Lokesh Agrawal

3/11/2008 10:36:00 AM

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
--
Posted via http://www.ruby-....

1 Answer

Todd Benson

3/11/2008 5:12:00 PM

0

On Tue, Mar 11, 2008 at 5:35 AM, Lokesh Agrawal
<lokesh_agrawal@persistent.co.in> wrote:
> 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

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

> values.each do |$status|
> end

I'm assuming that end was unintended/misplaced.

> 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.

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