<?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"
	>

<channel>
	<title>da.mned &#187; RT</title>
	<atom:link href="http://da.mned.co.uk/category/rt/feed/" rel="self" type="application/rss+xml" />
	<link>http://da.mned.co.uk</link>
	<description>- where I pollute the web -</description>
	<pubDate>Wed, 12 Nov 2008 14:27:23 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.2</generator>
	<language>en</language>
			<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.
I found a script on the wiki ( wiki.bestpractical.com  ) but it only [...]]]></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,&#8221;/usr/share/request-tracker3.6/lib/&#8221;;<br />
}<br />
use lib &#8220;/usr/uns/lib&#8221;;<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 />
        &#8220;user=s&#8221; => \$user,<br />
        &#8220;email=s&#8221; => \$email,<br />
        &#8220;passwd=s&#8221; => \$passwd<br />
);</p>
<p>CleanEnv();<br />
RT::LoadConfig();<br />
RT::Init();</p>
<p>print(&#8221;Creating user with the following variables\n&#8221;);<br />
print(&#8221;user : $user\n&#8221;);<br />
print(&#8221;e-mail : $email\n&#8221;);<br />
print(&#8221;password : $passwd\n&#8221;);</p>
<p>my $UserObj = new RT::User(RT::SystemUser);<br />
$UserObj->Create(Name => $user,<br />
                 EmailAddress => &#8220;$email&#8221;,<br />
                 Privileged => 1,<br />
                 Password => $passwd<br />
                );</p>
<p>print(&#8221;If there was no error it possibly worked!\n&#8221;);<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>
		</item>
	</channel>
</rss>
