From: Brad D. <br...@Di...> - 2003-03-18 21:08:20
|
I have written a simple script to load a bunch of users from an input file (comma separated data) into my directory service. This perl script uses Net::LDAP to add the entries. However, the load hangs on adding the first entry. From the server side, I never see an add request. So, it seems like the perl-ldap code is hanging for some reason. Have you seen this before? Here is an excerpt from the perl script: # # Establish LDAP connection to directory service # $ldap = new Net::LDAP ($opt_h, port=> $opt_p); # # will bind as specific user if specified else will be binded anonymously # $ldap->bind( $opt_D, password => $opt_w) || die "failed to bind as $opt_D"; ... # # Add each entry to the directory # $mycn = "$first_name $last_name"; $dn = "cn=$mycn, $base_suffix"; $result = $ldap->add( $dn, attrs => [ 'cn' => $mycn, 'sn' => $last_name, 'objectclass' => [ 'top', 'person', 'organizationalPerson', 'inetOrgPerson' ] ] ); Environment: OS: Red Hat Linux v8.0 Kernel: 2.4.18-14 Perl Version: v5.8.0 built for i386-linux-thread-multi perl-ldap version: perl-ldap-0.2701 Module Versions: Authen-SASL-2.03 Convert-ASN1-0.16 Net_SSLeay.pm-1.22 IO-Socket-SSL-0.92 Results from perl Makefile.PL Checking for OPTIONAL modules URI ..........................ok URI::ldap ....................ok Digest::MD5 ..................ok IO::Socket::SSL ..............ok XML::Parser ..................ok MIME::Base64 .................ok Authen::SASL .................ok Thanks in advance, Brad |
From: Brad D. <br...@Di...> - 2003-03-24 16:06:14
|
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 |
From: Peter M. <pe...@ad...> - 2003-03-24 16:33:40
|
Hi, On Monday 24 March 2003 17: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. Please give more details (a code snippet and an expract of the data) Otherwise it is really hard to guess what your problem might be. Peter --=20 Peter Marschall eMail: pe...@ad... |
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 |
From: Jim H. <ha...@us...> - 2003-03-24 20:19:15
|
Does it fail on the first thing from the file or further along? Do you need a chomp after your while to get rid of EOLs? Try setting $| to 1 and print messages with $dn before and after the $entry->update. --Jim Harle On 24 Mar 2003, Brad Diggs wrote: > 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 > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > |
From: Brad D. <br...@Di...> - 2003-03-24 21:59:31
|
Yes, the hang does occur on updating the first entry. I have set $| to 1 and I have tried chopping the $_ value before parsing with split. Unfortunately, these things didn't fix the problem. Printing the $dn before and after the update looks the same. Brad On Mon, 2003-03-24 at 14:18, Jim Harle wrote: > Does it fail on the first thing from the file or further along? Do you need a > chomp after your while to get rid of EOLs? Try setting $| to 1 and print > messages with $dn before and after the $entry->update. > --Jim Harle |
From: Brad D. <br...@Di...> - 2003-03-24 16:27:43
|
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 |
From: Brad D. <br...@Di...> - 2003-03-24 18:28:22
|
I forgot to mention that the error message that I get from applying the update. Here is the code that tells how the update handles the error: $result = $entry->update($ldap); die "Error: Add failed -> " . $result->error() . "\n" if $result->code(); Here is the error message: Error: Add failed -> I/O Error This sounds to me like a connection timeout because it took several minutes before I got the message. Could it be that the open and LDAP update request are attempting to use the same file handler? Brad |