[rt-users] How to automatically disable user account

Aaron Robinson robinsonaarond at gmail.com
Tue Sep 18 09:42:08 EDT 2012


Thank you!  That is exactly what I was missing.  I tried looking through
some other Perl scripts already in the folder to see what to "use," but
hadn't run across those.  I figured it would tell me, too, if it needed
anything else sourced.  At any rate, that fixed the problem.

One other thing, it turns out that

$user->SetDisabled();

doesn't actually work, as it needs a variable.  SetDisabled(1) will disable
account, while SetDisabled(0) will actually re-enable the account.  Threw
me off at first, but I'm good now.

Thanks again for the help!

- Aaron

On Tue, Sep 18, 2012 at 7:27 AM, Tim Cutts <tjrc at sanger.ac.uk> wrote:

>
> On 17 Sep 2012, at 22:54, aaronr <robinsonaarond at gmail.com> wrote:
>
> >
> > I am looking for this same information.
> >
> > I found this program from a few years ago, which is supposed to disable a
> > user:
> >
> > ---------
> > #! /usr/bin/perl -w
> >
> > use lib '/srv/www/rt4/lib';
> >
> >
> > use RT::Base;
> > use RT::Config;
> > use RT::User;
> >
> >
> > my $UserId = "sgeadmin";
> > my $user = RT::User->new($RT::SystemUser);
> > $user->Load($UserId);
> > $user->SetDisabled();
> > ---------
>
> It's missing some preamble needed to initialise the RT perl API.
>  Something like this:
>
> #! /usr/bin/perl -w
>
> use lib '/srv/www/rt4/lib';
>
> use RT;
> use RT::User;
>
> RT::LoadConfig;
> RT::Init;
>
> my $UserId = "sgeadmin";
> my $user = RT::User->new($RT::SystemUser);
> $user->Load($UserId);
> $user->SetDisabled();
>
> Should work.
>
> Tim
>
> --
>  The Wellcome Trust Sanger Institute is operated by Genome Research
>  Limited, a charity registered in England with number 1021457 and a
>  company registered in England with number 2742969, whose registered
>  office is 215 Euston Road, London, NW1 2BE.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20120918/175e692b/attachment.htm>


More information about the rt-users mailing list