return ($cn, $id);
}
+=item LiCoM::Person-E<gt>B<all_groups> ()
+
+Returns all defined groups. In scalar context returns a hash-ref with the
+group-names as keys and the number of group members as values. In list context
+returns a sorted list of group names.
+
+=cut
+
+sub all_groups
+{
+ my $pkg = shift;
+ my %retval = ();
+
+ my $mesg = $Ldap->search
+ (
+ base => $Config{'base_dn'},
+ filter => "(objectClass=groupOfNames)"
+ );
+
+ if ($mesg->is_error ())
+ {
+ warn ("Error while querying LDAP server: " . $mesg->error_text ());
+ return (qw());
+ }
+
+ for ($mesg->entries ())
+ {
+ my $entry = $_;
+ my ($name) = $entry->get_value ('cn', asref => 0);
+ my @members = $entry->get_value ('member', asref => 0);
+
+ $retval{$name} = scalar (@members);
+ }
+
+ if (wantarray ())
+ {
+ return (sort (keys %retval));
+ }
+ else
+ {
+ return (\%retval);
+ }
+}
+
=back
=head1 AUTHOR