Hi,

Using Net::LDAP .3202 on HPUX 11.11, I have the enviable task of regularly syncing the 
local /etc/passwd with LDAP for one old app that requires /etc/passwd entries.  In 
doing this, I need to make sure that the LDAP accounts that match /etc/passwd have a 
specific ObjectClass value.  Instead of spinning through an array, I thought it would 
be easier to check to see if a hash exists using the "alloptions" option of the 
get_value method, but I think I'm doing something wrong.  Here's the test I have so 
far:

#!/usr/bin/perl -w

use strict;
use Net::LDAP;

my ($Handle, $Message, $Entry, $UID, $ObjClass);

$Handle = Net::LDAP->new("myldapserver")||die "$@";
$Message = $Handle->bind;
$Message = $Handle->search(
                        base => "o=myorg",
                        filter => "uidNumber=2901",
                        attrs => ['ObjectClass', 'uid']);
$Message->code && die $Message->error;

foreach $Entry ($Message->entries) {
        $UID = $Entry->get_value("uid");
        print "$UID\n";
        $ObjClass = $Entry->get_value("ObjectClass", alloptions => 1);
        print "YES\n" if exists $ObjClass->{MyHPUXClass};
}

$Message = $Handle->unbind;

I don't think I'm using the $ObjClass hash ref correctly, as it never prints "YES" for 
MyHPUXClass or any other ObjectClass that I know exists for uidNumber 2901 (I used the 
"asref" option of get_value to verify).  I've tried several different variations, 
iterations, and incantations, but can't seem to figure this out.  A Google search 
showed examples, but every one spins thru all ObjectClass values, regarless of whether 
it was in an array or a hash.  I just want to determine if one value exists, 
preferably without spinning thru all values.

Ideas anyone?

TIA!
Rich

Rich Jesse
System/Database Administrator
QuadTech, Sussex, WI USA

Reply via email to