[rt-users] Modifying stuff with CLI, especially rights

Raed El-Hames Raed.El-Hames at daisygroupplc.com
Tue Mar 1 09:32:11 EST 2011


Lars

I might be wrong but I don’t think the cli cater for rights (groups or users),
I find the clicky clicky web interface annoying in particular when adding few users or few groups etc etc .. and to avoid that I ‘ve written scripts using the rt api (so its database/rt conformed) ….
My scripts are heavily customised for our business , I am willing to share but I would need to do a lot of stripping first, to save my time if you want to have a go yourself I use:

sub Addtogroup {
        my $uid = shift ; #This should be the user id , so you need to pull it out using RT::User->new(RT::SystemUser)->Load
        my $group = "Group_NAME_HERE";
        my $g = RT::Group->new(RT::SystemUser);
        $g->LoadUserDefinedGroup($group);
        unless ($g->id) {
                print "error loading group \n";
                return undef;
        }
        my ($gidm,$msg) =  $g->AddMember($uid);
        if ($gidm == 0) {
                 print "error adding user to group $msg\n";
        }
        return 1;
}

And for rights, I have something like:

my @rights = ('DeleteTicket','AssignCustomFields','OwnTicket','TakeTicket');
my $qobject = new RT::Queue(RT::SystemUser);
 $qobject->Load($queue);
my $gobject = new RT::Group (RT::SystemUser);
$gobject->LoadUserDefinedGroup($group);
my $gid = $gobject->Id;
my $principal = RT::Principal->new($RT::SystemUser);
$principal->Load($gid);

foreach my $right (@rights) {
            next unless ($right);
            my ($val, $msg) = $principal->GrantRight(Object => $qobject, Right => $right);
             push (@results, $msg);
}

Regards;
Roy


From: rt-users-bounces at lists.bestpractical.com [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Lars Reimann

Sent: 01 March 2011 13:30
To: rt-users at lists.bestpractical.com
Subject: [rt-users] Modifying stuff with CLI, especially rights

Hi all,

i've done some digging since we are having the need to alter / edit stuff within RT programatically via the built-in CLI.

However, I find the general documentation sparse and can only agree with previous questions which have gone unanswered / unsolved.

Modifying stuff such as rights for a user should be possible with CLI, but syntax and method is still unknown (at least to me) after a close look at things.

What we (and basically other users) need would be the approach to add users to specific groups and modify access rights for those groups (its a pain to clicky clicky on the web-interface for admins).

I understand that the CLI is basically a wrapper for the underlying perl code. I would rather use the CLI to be database conform / rt conform than devising a way to solve my problems in an unclean way.
Please update / tell us more about solving things via the CLI.

Updating the Wiki may be also a good step, but that can also be done by me, once the general approach / scope is clear.


e.g. References:
Batch Rights modification with CLI<http://www.gossamer-threads.com/lists/rt/users/90712?search_string=rights%20cli;#90712> Dec 10, 2009, 6:49 AM
Using CLI to modify group rights on a queue - is it possible?  <http://www.gossamer-threads.com/lists/rt/users/84106?search_string=rights%20cli;#84106> Mar 20, 2009, 9:44 AM


greetings,
l.r.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110301/ba8dbaba/attachment.htm>


More information about the rt-users mailing list