Closed Bug 1574 Opened 26 years ago Closed 20 years ago

RFE: new add() and modify() methods/functionality

Categories

(Directory :: PerLDAP, enhancement, P5)

All
Solaris
enhancement

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: leif, Assigned: leif)

Details

From: kburns@netscape.com (Kevin L. Burns) Third, I added two new functions to Conn.pm. Both are almost completely the same as add(). The first one I've called cc_add(). This is the same as add() only it returns $ret (the return value from ldap_add_s). I did this since LDAP_SUCCESS is 0. In an if statement in perl, 0 and false should work the same, e.g. if(0) if(undef()) and if(1 == 2) should all evaluate to false. Also, for a lot of reasons you probably don't care about, I never use an entry object, only a conn object. This makes your update() function break. To solve this I made a copy of cc_add() and changed the call from ldap_add_s to ldap_modify_s and called it cc_modify(). These were all trivial changes, but if you want them, they are below. ############################################################################# # Modify an object sub cc_modify { my ($self, $entry) = @_; my ($ref, $key, $val, %ent); my $ret = 1; my $gotcha = 0; $ref = ref($entry); if (($ref eq "Mozilla::LDAP::Entry") || ($ref eq "HASH")) { foreach $key (keys %{$entry}) { next if (($key eq "dn") || ($key =~ /^_.+_$/)); $ent{$key} = $entry->{$key}; $gotcha++; } $ret = ldap_modify_s($self->{"ld"}, $entry->{"dn"}, \%ent) if $gotcha; } return($ret); } ############################################################################# # Add an object sub cc_add { my ($self, $entry) = @_; my ($ref, $key, $val, %ent); my $ret = 1; my $gotcha = 0; $ref = ref($entry); if (($ref eq "Mozilla::LDAP::Entry") || ($ref eq "HASH")) { foreach $key (keys %{$entry}) { next if (($key eq "dn") || ($key =~ /^_.+_$/)); $ent{$key} = $entry->{$key}; $gotcha++; } $ret = ldap_add_s($self->{"ld"}, $entry->{"dn"}, \%ent) if $gotcha; } return($ret); } -- Kevin L. Burns mailto:kburns@netscape.com NetCenter Product Development http://people.netscape.com/kburns Netscape Communications
Status: NEW → ASSIGNED
Here are the working versions of cc_add & cc_modify. --kburns@netscape.com ############################################################################# # Modify an object sub cc_modify { my ($self, $entry) = @_; my ($ref, $key, $val, %ent, @vals); my $ret = 1; my $gotcha = 0; $ref = ref($entry); if (($ref eq "Mozilla::LDAP::Entry") || ($ref eq "HASH")) { foreach $key (keys %{$entry}) { next if (($key eq "dn") || ($key =~ /^_.+_$/)); @vals = @{$entry->{$key}}; $ent{$key} = {"r", [@vals]}; $gotcha++; } $ret = ldap_modify_s($self->{"ld"}, $entry->{"dn"}, \%ent); } return($ret); } ############################################################################# # Add an object sub cc_add { my ($self, $entry) = @_; my ($ref, $key, $val, %ent); my $ret = 1; my $gotcha = 0; $ref = ref($entry); if (($ref eq "Mozilla::LDAP::Entry") || ($ref eq "HASH")) { foreach $key (keys %{$entry}) { next if (($key eq "dn") || ($key =~ /^_.+_$/)); $ent{$key} = $entry->{$key}; $gotcha++; } $ret = ldap_add_s($self->{"ld"}, $entry->{"dn"}, \%ent) if $gotcha; } return($ret); }
Priority: P2 → P5
Don't think we need these.
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.