Hey Chris,
Hmmm...very interesting! I tried the first one and it works (I was worried about
partial matches, but now I see the start/end word regexp), and yes, asref and the
second would probably be better for my program. I'm sure I can use this, but...
I'm confused about the hash itself. It's probably a lack of Perl knowledge, but why
can't:
$oc->{MyHPUXClass}
...be used to determine if that value is present?
Thanks!
Rich
-----Original Message-----
From: Chris Ridd [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 21, 2004 12:44 PM
To: Jesse, Rich; [EMAIL PROTECTED]
Subject: Re: How to determine if ObjectClass value exists in LDAP
record?
On 21/10/04 6:19 pm, Jesse, Rich <[EMAIL PROTECTED]> wrote:
> Yes, I thought of that too, after some RTFMing. The kicker is that the LDAP
> record could exist, but without that particular ObjectClass. If I used the
> filter, I would have to report such a record as "non existant", when actually
> it's just the ObjectClass that's missing -- it would add confusion to the
> folks that would be maintaining the user accounts.
>
> Thanks for the suggestion, though!
Rich, this ought to work for you:
$oc = $entry->get_value("objectclass", alloptions => 1);
if (grep /^MyHPUXClass$/i, @{$oc->{''}}) {
# do your thing
}
I'm sure that alloptions is much use for you in this case, and perhaps using
asref => 1 would be better. Or even, frankly, a plain
get_value('objectclass') in a list context.
if (grep /^MyHPUXClass$/i, $entry->get_value('objectclass')) {
# found it
}
Cheers,
Chris