List of privileged users

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;

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
}

$RT::Handle->Disconnect();

Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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.

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;

right. I took that code from another script without realizing this obvious
change.

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”;

excellent! thanks a lot!

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.

Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

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;

right. I took that code from another script without realizing this obvious
change.

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”;

excellent! thanks a lot!

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.

how do I run this code with a script account which has no account on RT?

Is it possible to feed a valid account/password in a .rtrc file or
something similar
that the script account will use to connect to RT and generate the report?

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.


Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

Asif Iqbal
PGP Key: 0xE62693C5 KeyServer: pgp.mit.edu
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

how do I run this code with a script account which has no account on RT?

Is it possible to feed a valid account/password in a .rtrc file or something similar
that the script account will use to connect to RT and generate the report?

Your script is already running without using an account in RT, since you created the RT::Tickets object using $RT::SystemUser.

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.