[rt-users] How to list all enabled users in Perl script?

Ruslan Zakirov ruz at bestpractical.com
Tue Sep 3 05:04:58 EDT 2013


Call `print $RT_enabled_users->BuildSelectQuery, "\n";`, check SQL manually
and it is correct then move to Next function.


On Mon, Sep 2, 2013 at 6:04 PM, Nathan Cutler <presnypreklad at gmail.com>wrote:

> Greetings:
>
> RT 4.0.17.  In the web UI, when I list all enabled users by selecting
> '%' I get a list of about 152 users (approximately). Now, I have
> written a Perl script that is supposed to list all enabled RT users.
> When I run it, it finds 147 users and lists them in alphabetical
> order. But approximately 5 users at the end of the alphabet ('Name'
> starting with 'v', 'w', 'x', 'y', or 'z') are missing. For the life of
> me I can't figure out why. Any ideas?
>
> use strict;
> use warnings;
>
> use RT;
> use RT::User;
> use RT::Users;
>
> BEGIN {
>     RT->LoadConfig;
>     RT->Init;
> }
>
> my $RT_enabled_users = RT::Users->new($RT::SystemUser);
> $RT_enabled_users->LimitToEnabled;
>
> my $loop_count = 0;
> while (my $current_user = $RT_enabled_users->Next) {
>
>    $loop_count += 1;
>
>    my $uid = $current_user->Name;
>    my $real_name = $current_user->RealName;
>    my $rt_email = $current_user->EmailAddress;
>
>    print "$loop_count: '$uid' -- $real_name -- $rt_email\n";
>
> }
>
> print "Loop count: $loop_count\n";
>
> Thanks alot,
> Nathan
>



-- 
Best regards, Ruslan.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20130903/81b74c8e/attachment.htm>


More information about the rt-users mailing list