Hi All,

I am new to Ruby and doing some automation testing.

I am using Net::LDAP to connect to my ldap server
My script is

require 'rubygems'
require 'net/ldap'

ldap = :host => '',
      :port => 389,
      :auth => {
            :method => :simple,
            :username => "cn=Manager,dc=ibm,dc=com",
            :password => "secret"

#if ldap.bind
#puts ldap.inspect
#puts ldap.get_operation_result.message

filter = Net::LDAP::Filter.eq( "mail", "" )
treebase = "dc=ibm,dc=com"
attrs = ["userPassword"] :base => treebase, :filter => filter, :attributes => attrs
) do |entry|

   entry.each do |attribute, values|
     values.each do |value|
       puts "#{value}"


I am getting my expected result

Now I want to save the value lI6z#f5C (which is attribute password) and in to 2 seperate variables say $passwd and $mail so
that I can use these values for some other purpose.

Can anyone help me how can I do that.