The ability to delete entries has been added.
[licom.git] / lib / LiCoM / Person.pm
index cbc2eab..564d208 100644 (file)
@@ -29,7 +29,8 @@ our %ValidFields =
        labeledURI                      => 1,
        mail                            => 1,
        mobile                          => 1,
-       o                               => 1
+       o                               => 1,
+       userPassword                    => 0
 );
 
 our %ExternalNames =
@@ -44,7 +45,8 @@ our %ExternalNames =
        uri             => 'labeledURI',
        mail            => 'mail',
        cellphone       => 'mobile',
-       group           => 'o'
+       group           => 'o',
+       password        => 'userPassword'
 );
 
 our $Ldap;
@@ -291,7 +293,16 @@ sub search
                        
                if (@disjunc)
                {
-                       push (@konjunct, join ('', '(|', @disjunc, ')'));
+                       my $tmp;
+                       if (scalar (@disjunc) == 1)
+                       {
+                               $tmp = $disjunc[0];
+                       }
+                       else
+                       {
+                               $tmp = join ('', '(|', @disjunc, ')');
+                       }
+                       push (@konjunct, $tmp);
                }
        }
 
@@ -433,7 +444,8 @@ sub name
 
 =item I<$obj>-E<gt>B<group> ([I<@groups>])
 
-Get or set the attribute.
+Get or set the attribute. This is the same as calling S<I<$obj>-E<gt>B<set>
+(I<$field>, I<\@values>)> or S<I<$obj>-E<gt>B<get> (I<$field>)>.
 
 =cut
 
@@ -450,14 +462,34 @@ sub AUTOLOAD
        return (set ($obj, $field, @values ? [@values] : undef))
 }
 
+=item I<$obj>-E<gt>B<get> (I<$field>)
+
+Returs the value(s) of field I<$field>.
+
+=cut
+
 sub get
 {
        my $obj = shift;
        my $field = shift;
 
-       return (set ($obj, $field, undef));
+       if (wantarray ())
+       {
+               return (set ($obj, $field, undef));
+       }
+       else
+       {
+               return (scalar (set ($obj, $field, undef)));
+       }
 }
 
+=item I<$obj>-E<gt>B<set> (I<$field>, I<\@values>)
+
+Sets the field I<$field> to the value(s) I<\@valued>. Pass an empty array-ref
+to delete the field.
+
+=cut
+
 sub set
 {
        my $obj = shift;
@@ -544,23 +576,6 @@ sub get_user
        return ($cn, $id);
 }
 
-sub password
-{
-       my $obj = shift;
-       my $entry = $obj->{'ldap'};
-       my $pwd;
-
-       if (@_)
-       {
-               $pwd = shift;
-               $entry->changetype ('modify');
-               $entry->replace (userPassword => $pwd);
-               $entry->update ($Ldap);
-       }
-
-       $pwd = $entry->get_value ('userPassword');
-}
-
 =back
 
 =head1 AUTHOR