On 15 Jun 2012, at 07:52, Asif Iqbal wrote:

> How do I get the list of privleged users?
> 
> This is what I have so far
> 
> #!/usr/bin/perl -w
>  
>  use strict;
>  use Carp;
>  use Getopt::Long;
>  
>  use lib qw(/opt/rt3/lib /opt/rt3/etc);
>  
>  use RT::Interface::CLI qw(CleanEnv GetCurrentUser GetMessageContent loc);
>  CleanEnv();
>  
>  use RT;

>  use RT::Ticket;
>  use RT::Tickets;

Don't you mean:

use RT::Users;

instead of the above two lines?

>  
>  RT::LoadConfig();
>  
>  RT::Init();
>  
>  my $PrivilegedUsers = RT::Users->new ( $RT::SystemUser );
>  $PrivilegedUsers->LimitToPrivileged;
> 
> 
>  while ( my $PrivilegedUser = $PrivilegedUsers->Next ) {
>         print $PrivilegedUser."\n";  # <== this only prints hash

$PrivilegedUser is a reference  to a perl object (hence you get the class name 
and an identifier for the object).  In order to get the data out of the object, 
you have to call an accessor method:

print $PrivilegedUser->Name, "\n";

or

print $PrivilegedUser->EmailAddress, "\n";

depending on what you want.

>  }
> 
>  $RT::Handle->Disconnect();

I don't think you need that bit - it'll all be closed cleanly as the script 
exits anyway.

Tim

--
 The Wellcome Trust Sanger Institute is operated by Genome Research
 Limited, a charity registered in England with number 1021457 and a
 company registered in England with number 2742969, whose registered
 office is 215 Euston Road, London, NW1 2BE.

Reply via email to