I’m trying to get a list of all privileged users in our system. Which
table.field should I be querying against?
Mathew
I’m trying to get a list of all privileged users in our system. Which
table.field should I be querying against?
Mathew
To clarify, this query is for a stand-alone script which will be pulling
data based on the users and will run outside of RT.
Mathew
Mathew Snyder wrote:
Mathew;
Querying the database will be complex involving Users and Principals
tables and I think you may need to also include the Groups table, will
be much simpler to use the RT API , the function you need will be
somthing like:
use RT::Users
my $users = new RT::Users(RT_System);
$users->LimitToPrivileged;
(look in (Admin/Users/index.html)
Regards;
Roy
Mathew Snyder wrote:
I’ve created a simple script and placed it in local/sbin. When I run it I get “Can’t locate
RT/Users.pm in @INC…”. How do I add RT to the list of @INC directories?
Of course, my perl skills are still rudimentary at best so I may have it all wrong:
#!/usr/bin/perl
use RT::Users;
use strict;
use warnings;
my $users = new RT::Users(RT_System);
$users->LimitToPrivileged;
print $users;
Mathew
Roy El-Hames wrote:
Mathew;
I am assuming your RT is in /opt/rt3
So what you need is:
#!/usr/bin/perl
use lib “/opt/rt3/lib”;
use RT;
use RT::Users ; ## you may not need this but what the he
use warnings;
CleanEnv(); ##Clening the env
RT::LoadConfig(); ## Loading RT config
RT::Init(); ## Initialise RT
my $users = new RT::Users(RT_System);
$users->LimitToPrivileged;
while ( $user = $users->Next) {
print $user->Name ;
}
exit;
stick in /opt/rt3/bin and run it; it should work.
Roy
Mathew Snyder wrote:
Cool, thanks. It never occurs to me to to look at the API and try to sort it
out. I guess that’s why I’m going to the training in Boston
I ran this though and got the following error:
Undefined subroutine &main::CleanEnv called at ./report_test2.pl line 6.
Mathew
Roy El-Hames wrote:
Mathew;
hmm not sure it ran ok with 3.4.4 …
Remove the line
CleanEnv();
its not that nesseccary
Roy----- Original Message -----
From: “Mathew Snyder” theillien@yahoo.com
To: “Roy El-Hames” rfh@pipex.net
Cc: rt-users@lists.bestpractical.com
Sent: Saturday, November 18, 2006 5:47 AM
Subject: Re: [rt-users] Privileged Users
Cool, thanks. It never occurs to me to to look at the API and try to sort
it
out. I guess that’s why I’m going to the training in BostonI ran this though and got the following error:
Undefined subroutine &main::CleanEnv called at ./report_test2.pl line 6.Mathew
Roy El-Hames wrote:
Mathew;
I am assuming your RT is in /opt/rt3
So what you need is:#!/usr/bin/perl
use lib “/opt/rt3/lib”;
use RT;
use RT::Users ; ## you may not need this but what the he
use warnings;
CleanEnv(); ##Clening the env
RT::LoadConfig(); ## Loading RT config
RT::Init(); ## Initialise RTmy $users = new RT::Users(RT_System);
$users->LimitToPrivileged;while ( $user = $users->Next) {
print $user->Name ;
}
exit;stick in /opt/rt3/bin and run it; it should work.
Roy
Mathew Snyder wrote:
I’ve created a simple script and placed it in local/sbin. When I run
it I get “Can’t locate
RT/Users.pm in @INC…”. How do I add RT to the list of @INC
directories?Of course, my perl skills are still rudimentary at best so I may have
it all wrong:
#!/usr/bin/perl
use RT::Users;
use strict;
use warnings;my $users = new RT::Users(RT_System);
$users->LimitToPrivileged;
print $users;Mathew
Roy El-Hames wrote:
Mathew;
Querying the database will be complex involving Users and Principals
tables and I think you may need to also include the Groups table,
will
be much simpler to use the RT API , the function you need will be
somthing like:
use RT::Users
my $users = new RT::Users(RT_System);
$users->LimitToPrivileged;
(look in (Admin/Users/index.html)
Regards;
RoyMathew Snyder wrote:
I’m trying to get a list of all privileged users in our system. Which
table.field should I be querying against?Mathew
Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.comDiscover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com
Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.comDiscover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com–
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.7/537 - Release Date: 17/11/2006
Yeah, I commented it out and it ran find. I’m guessing though, that all the
errors that I’m getting:
[Sun Nov 19 08:59:35 2006] [err]: RT::User=HASH(0xaea2ed4) was created without a
CurrentUser 1 (/usr/local/rt-3.6.1/lib/RT/Base.pm:92)
are from not running this as an authenticated user? There’s a bunch of them
right before it spits out the results I’m looking for.
Mathew
Raed El-hames wrote:
Quoting Mathew Snyder theillien@yahoo.com:
Yeah, I commented it out and it ran find. I’m guessing though, that all the
errors that I’m getting:[Sun Nov 19 08:59:35 2006] [err]: RT::User=HASH(0xaea2ed4) was
created without a
CurrentUser 1 (/usr/local/rt-3.6.1/lib/RT/Base.pm:92)are from not running this as an authenticated user? There’s a bunch of them
right before it spits out the results I’m looking for.Mathew
my $users = new RT::Users(RT_System);
Mat,
Try
my $users = new RT::Users(RT::SystemUser);