Please help

L

Lokesh Agrawal

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
 
T

Todd Benson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top