thendal
Programmer
- Aug 23, 2000
- 284
Hi all!
I am retriving a set of values from a ldap server, the values are attribute name and the value it holds...i collect this values in a hash...
say something like this
foreach $attr (@aarry)
{
$hold{$attr}=$value
}
If my ldap search yield more than one result then i have write one more foreach loop over this...
say something like this
foreach $entry (@entries)
{
foreach $attr (@aarry)
{
$hold{$attr}=$value
}
}
problem here is for second set of result the attribute name(ie key) is going to be same but the values will change.
so its going to over write values.
Don't know how to solve this so i tried something like this
$k=1;
foreach $entry (@entries)
{
foreach $attr (@aarry)
{
$hold.$k{$attr}=$value;
--
}
$k++;
}
Didn't work ..i haven't used hashes a lot any ideas will be really appreciated.
Thank you
This code may not make sense uses NET-LDAP module.
I am retriving a set of values from a ldap server, the values are attribute name and the value it holds...i collect this values in a hash...
say something like this
foreach $attr (@aarry)
{
$hold{$attr}=$value
}
If my ldap search yield more than one result then i have write one more foreach loop over this...
say something like this
foreach $entry (@entries)
{
foreach $attr (@aarry)
{
$hold{$attr}=$value
}
}
problem here is for second set of result the attribute name(ie key) is going to be same but the values will change.
so its going to over write values.
Don't know how to solve this so i tried something like this
$k=1;
foreach $entry (@entries)
{
foreach $attr (@aarry)
{
$hold.$k{$attr}=$value;
--
}
$k++;
}
Didn't work ..i haven't used hashes a lot any ideas will be really appreciated.
Thank you
This code may not make sense uses NET-LDAP module.
Code:
foreach $entry ($result->entries)
{
# print $entry->dump;
foreach $attr ( sort $entry->attributes )
{
next if ($attr =~ /;binary$/ );
[COLOR=red] $hold{$attr}=$entry->get_value($attr);[/color]
## i am storing attribute as key and values as thier values
print " $attr : ", $entry->get_value ($attr), "\n";
$k++;
}
}