Net::LDAP

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 = Net::LDAP.new :host => '10.44.169.24',       :port => 389,       :auth => {             :method => :simple,             :username => "cn=Manager,dc=ibm,dc=com",             :password => "secret"       }

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

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

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

     end    end end

I am getting my expected result i.e.

mail=lokesh@yahoo.com,ou=people,o=external,dc=ibm,dc=com lI6z#f5C

Now I want to save the value lI6z#f5C (which is attribute password) and lokesh@yahoo.com 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.