<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>da.mned &#187; Adding users</title>
	<atom:link href="http://da.mned.co.uk/tag/adding-users/feed/" rel="self" type="application/rss+xml" />
	<link>http://da.mned.co.uk</link>
	<description>- where I pollute the web -</description>
	<lastBuildDate>Sat, 07 Jan 2012 22:56:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>RT Command Line adding users</title>
		<link>http://da.mned.co.uk/2008/03/rt-command-line-adding-users/</link>
		<comments>http://da.mned.co.uk/2008/03/rt-command-line-adding-users/#comments</comments>
		<pubDate>Tue, 11 Mar 2008 19:49:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[RT]]></category>
		<category><![CDATA[Adding users]]></category>
		<category><![CDATA[Request Tracker]]></category>

		<guid isPermaLink="false">http://da.mned.co.uk/2008/03/11/rt-command-line-adding-users/</guid>
		<description><![CDATA[A while a go I needed to add a whole raft of users (about 400 or so ) to our work RT system. Doing this manually had little appeal so I was looking for a scriptable way of doing it. &#8230; <a href="http://da.mned.co.uk/2008/03/rt-command-line-adding-users/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while a go I needed to add a whole raft of users (about 400 or so <img src='http://da.mned.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) to our work RT system.  Doing this manually had little appeal so I was looking for a scriptable way of doing it.</p>
<p>I found a script on the wiki ( wiki.bestpractical.com  ) but it only supported populating RT from /etc/passwd entires.  So close and yet&#8230; so with a pointer or two from Bunty, my handy online Perl guru friend <img src='http://da.mned.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   I managed to use the existing script and bodge it to allow command line arguements <img src='http://da.mned.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code><br />
#!/usr/bin/perl -w<br />
#<br />
# rtadduser: add a local user to RT<br />
# David Maze <dmaze@cag.lcs.mit.edu><br />
# $Id$<br />
# Poorly modified by Tig to accept commandline arguments<br />
# Known issues,  will silently fail if a user already exists</p>
<p>BEGIN{<br />
        push @INC,"/usr/share/request-tracker3.6/lib/";<br />
}<br />
use lib "/usr/uns/lib";<br />
use strict;<br />
use English;<br />
use RT::Interface::CLI qw(CleanEnv);<br />
use RT::User;<br />
use Getopt::Long;</p>
<p>my ($user, $passwd, $email);</p>
<p>GetOptions (<br />
        "user=s" => \$user,<br />
        "email=s" => \$email,<br />
        "passwd=s" => \$passwd<br />
);</p>
<p>CleanEnv();<br />
RT::LoadConfig();<br />
RT::Init();</p>
<p>print("Creating user with the following variables\n");<br />
print("user : $user\n");<br />
print("e-mail : $email\n");<br />
print("password : $passwd\n");</p>
<p>my $UserObj = new RT::User(RT::SystemUser);<br />
$UserObj->Create(Name => $user,<br />
                 EmailAddress => "$email",<br />
                 Privileged => 1,<br />
                 Password => $passwd<br />
                );</p>
<p>print("If there was no error it possibly worked!\n");<br />
</code></p>
<p>To use this you will need  Getopt::Long installed,  usage is :</p>
<p><code> perl rtadduser -user=username -email=user@foo.com -passwd=secretpassword</code></p>
<p>Oh and you will need to poke line 10 (the one with the path to RT.pm) for your distro.</p>
<p>I will put this onto the wiki soon,  just needed to dump it somewhere indexable before I forget about it <img src='http://da.mned.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://da.mned.co.uk/2008/03/rt-command-line-adding-users/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

