[rt-users] CLI: manipulating "privileged" status

Stuart J. Browne sjbrowne at bluebottle.com
Tue Aug 22 22:09:02 EDT 2006


> -----Original Message-----
> From: rt-users-bounces at lists.bestpractical.com 
> [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf 
> Of Ole Craig
> Sent: Wednesday, August 23, 2006 11:36 AM
> To: Torsten Brumm
> Cc: rt-users at lists.bestpractical.com
> Subject: Re: [rt-users] CLI: manipulating "privileged" status
> 
> On Tue, 2006-08-22 at 12:06 +0200, Torsten Brumm wrote:
> > and read with this sh scrip from csv file:
> [...]
> > 
> > 2006/8/22, Torsten Brumm <torsten.brumm at googlemail.com>:
> >         Try the following sniplet:
> [...]
> 
> Torsten -
>         Thanks muchly! I'll give it a whirl tonight. Looks like this
> creates the user and sets privileged at the same time? Or does
> 
>          $User->Create()
> 
> allow modification of existing users as well as creation of new ones?

I've always used:

#
# create as a new user, putting the first address in a few places for easy
recognition
#
        my %UserDetails = (
            'Name' => $user,
            'EmailAddress' => $user,
            'ExternalContactInfoId' => $uid,
            'Comments' => "Auto-created upon user creation",
            'Gecos' => substr($uid, 0, index($uid, '@'))
        );
        my ($status, $msg) = $User->Create(%UserDetails);
        if ($status) {
            print "Done.\n";
        } else {
            printf("Failed (%s).\n", $msg);
            exit(1);
        }
    }
#
# If we still don't have a User ID, die off
#
    unless ($User->id) {
        printf("Whoa, something really odd happened!  User should have been
created (%s)!\n", $user);
        exit(2);
    };
#
# Make sure the user can take privileges.  Do this here instead of upon
creation, as the user might already exist
#
    printf("Found user (%s::%d).  Checking privileges setting: ", $user,
$User->id);
    if ($User->Privileged()) {
        print "Yes.\n";
    } else {
        print "No. Granting.. ";
#
# They didn't have privs.  Give them to the user
#
        if ($User->SetPrivileged(1)) {
            print "Done.\n";
        } else {
            print "Failed.\n";
            exit(1);
        }
    }





More information about the rt-users mailing list