|
From: Brad D. <br...@Di...> - 2003-03-24 17:20:21
|
This appears to be an issue when trying to perform an LDAP operation
in the context of an open,while,close loop of reading through an input
file. When I comment out the open,while,close loop, the entry gets
added
just fine. However, when I put it back in the context of a input file
loop,
the LDAP update function hangs.
Here is sample code to illustrate what I am doing...
if (-f "$opt_f") {
#
# Establish LDAP connection to directory service
#
$ldap = Net::LDAP->new($opt_h, port=> $opt_p)
or die "Can't connect to LDAP server $opt_h:$opt_p\n";
$ldap->bind($opt_D, password => $opt_w)
or print "Can't bind to LDAP server as $opt_D";
open(INPUTFILE, "< $opt_f");
while (<INPUTFILE>) {
#
# Parse the comma delimited file
#
($last_name,$first_name) = split(/\,/, $_);
#
# Add each entry to the directory
#
$mycn = "$first_name $last_name";
$dn = "cn=$mycn, $opt_b";
print "Adding $first_name, $last_name, $email1 to $opt_h:$opt_p
via $opt_D:$opt_w\n";
$entry = Net::LDAP::Entry->new();
$entry->dn("$dn");
$entry->changetype('add');
$entry->add('cn' => "$mycn");
$entry->add('objectclass' => ['top', 'person',
'organizationalPerson', 'inetOrgPerson']);
$entry->add('sn' => "$last_name");
$entry->add('givenName' => "$first_name") if defined
$first_name;
#
# Apply the update
#
$result = $entry->update($ldap);
die "Error: Add failed -> " . $result->error() . "\n" if
$result->code();
print "Finished Adding " . $entry->dn() . " with result
$result->code\n";
}
close(INPUTFILE);
$ldap->unbind();
}
Anybody know whats wrong or if there are any workarounds. Ideally,
I would prefer not creating large arrays that I would use to replay the
updates through.
Thanks in advance,
Brad
On Mon, 2003-03-24 at 10:04, Brad Diggs wrote:
> I have performed numerous tests using various methods of adding
> entries from an input file using open. The hang always occurs
> when the entry update is applied. The problem is that the update
> is never applied.
>
> Has anyone experienced this problem before?
>
> Thanks again!
>
> Brad
|