[rt-devel] NIS -> local rt users script

Gwendolynn ferch Elydyr gwen at reptiles.org
Thu Nov 27 12:43:38 EST 2003


Hola -

I grew a quick script out of Dave Maze's script to add local users to
RT to import users from NIS with their current crypted password, and
thought that others might find it useful:

=======

#!/usr/local/bin/perl -w
#
# rtadduser: add a local user to RT
# David Maze <dmaze at cag.lcs.mit.edu>
# $Id$
#
# 2003-11-27 Modified by gwen at reptiles.org for the local environment
#       changed to read from ypcat
#
# Don't forget to modify the email address field appropriately.

use strict;
use English;

# specify where to find the RT libs, which are in a non-standard path,
# and thus not in @INC
use lib qw(/usr/local/rt3/lib);

use RT::Interface::CLI qw(CleanEnv);
use RT::User;

# pipe the results of the command 'ypcat passwd' into a filehandle
# this is lazy, and presumes that ypcat is in your path
open USERS, "ypcat passwd|";

CleanEnv();
RT::LoadConfig();
RT::Init();

while (<USERS>)
        {
        my ($name, $passwd, $uid, $gid, $gcos, $dir, $shell) = split /:/ ;

        my $UserObj = new RT::User($RT::SystemUser);
        $UserObj->Create(Name => $name,
                EmailAddress => "$name\@example.com",
                RealName => $gcos,
                CryptedPassword => $passwd,
                Privileged => 1);
   }


==========================================================================
"A cat spends her life conflicted between a deep, passionate and profound
desire for fish and an equally deep, passionate and profound desire to
avoid getting wet.  This is the defining metaphor of my life right now."




More information about the Rt-devel mailing list