Fellow LDAPers, I have dozens of Net::LDAP, Entry, LDIF, Schema etc based scripts (Open Source rocks!).
However, I keep finding myself in the same situation wishing I had a more dynamic approach towards handling multi-valued attributes. I suppose I could ALWAYS use array references even for attrs that I know are single valued: ie "$rarray = $entr->get_value->($some_specific_attr, asref => 1)". Where the "{asref => 1}" option forces an array ref for the returned value even if its only single valued. But then I really don't want to deal with $$rarray[0], or if (scalar @$array == 1) etc?? A little bit poking around the Net::LDAP::Schema seems to indicate that if (! exists $schema->attribute->('some_specifc_attr')->{single-value}) { # it's multi-valued - ie; the 'single-value' is set to '1' but I don't see any set to zero, rather the key just doesn't exist if its multi-valued. else #its single valued. But the schema is really big and I'd have to somehow cache/stash the small parts of this monster that I'd need throughout the lifetime of the script;-) Today I typically have static constants files that are like: our @multi_value_attrs = qw[mail, memberof, etc] and check this every time I fetch or process attributes. if (some_specific_attr in @multi_value_attrs) { @answers = $entr->get_value('some_specific_attr'); #array } else { $answer = $entr->get_value('some_specific_attr'); #scalar } Its very inelegant... I see many posts out there explaining the whole "fetch multi-valued attributes as an array and single valued attributes as scalars" but no simple way of knowing dynamically which to expect. Does anyone have an inexpensive function like: $entr->is_multi_valued('some_specific_attr')? Or maybe it's just my approach that is flawed? Thanks all! --Dan