> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of Ole Craig
> Sent: Wednesday, August 23, 2006 11:36 AM
> To: Torsten Brumm
> Cc: rt-users@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 <[EMAIL PROTECTED]>:
> >         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);
        }
    }


_______________________________________________
http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: [EMAIL PROTECTED]


Discover RT's hidden secrets with RT Essentials from O'Reilly Media. 
Buy a copy at http://rtbook.bestpractical.com

Reply via email to