-sub get_user
-{
- my $pkg = shift;
- my $dn = shift;
- my ($search) = $dn =~ m/cn\s*=\s*([^,]+)/i;
-
- die unless ($search);
-
- my $cn = '';
- my $id = '';
-
- my $mesg = $Ldap->search
- (
- base => $Config{'base_dn'},
- filter => "(cn=$search)"
- );
-
- if ($mesg->is_error ())
- {
- warn ("Error while querying LDAP server: " . $mesg->error_text ());
- return ('');
- }
-
- for ($mesg->entries ())
- {
- my $e = $_;
- my ($t_cn) = $e->get_value ('cn', asref => 0);
- my ($t_id) = $e->get_value ('uid', asref => 0);
-
- if (!$id or $t_id)
- {
- $cn = $t_cn;
- $id = $t_id;
- }
- }
-
- 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);
- }
-}
-