Hi Gene,
There probably is a better way... But heres the way that one of my
guys solved it many moons ago in a previous version. I’m not sure if its
the right way, if this even exists in the version you run, etc.
In the config.pm there is a section called :
LookupExternalUserInfo
At the time it allowed you to sync incoming users with an
external data source.
We put the following into it :
sub LookupExternalUserInfo {
my ($EmailAddress, $RealName) = @_;
my $FoundInExternalDatabase = undef;
my %params;
#Name is the RT username you want to use for this user.
$params{‘Name’} = $EmailAddress;
$params{‘EmailAddress’} = $EmailAddress;
$params{‘RealName’} = $RealName;
$RT::Logger->debug(“LookupExternalUserInfo: Entered with:\n”,
“\tName = $params{‘Name’}\n”,
lAddress = $params{‘EmailAddress’}\n",
“\tRealName = $params{‘RealName’}\n”,
“\tFound = $FoundInExternalDatabase\n”);
See RT’s contributed code for examples.
$findkey= lc($EmailAddress);
tie (%fdbi,‘NDBM_File’,“/usr/local/rt2/etc/keyedfile”,O_RDWR,0777) or die $!;
if ($fdbi{$findkey}) {
$params{‘Orig’} = “$EmailAddress”;
chomp($params{‘Orig’});
($params{‘Name’},$params{‘EmailAddress’})=split(/|/,$fdbi{$findkey});
chomp($params{‘Name’});
$params{‘RealName’} = “$params{‘Name’}”;
chomp($params{‘RealName’});
chomp($params{‘EmailAddress’});
$FoundInExternalDatabase = 1;
}else {
$FoundInExternalDatabase = undef;
}
untie %fdbi;
$RT::Logger->debug("LookupExternalUserInfo: Leaving local file ",
“examination with:\n”,
“\tName = "$params{‘Name’}"\n”,
“\tEmailAddress = $params{‘EmailAddress’}\n”,
“\tRealName = $params{‘RealName’}\n”,
“\tOrig = $params{‘Orig’}\n”,
“\tFound = $FoundInExternalDatabase\n”);
return ($FoundInExternalDatabase, %params);
}
We then created a file formatted like :
#Format is ALTERNATE_EMAIL_ADDRESS:RT_LOGIN_ID|PRIMARY_EMAIL_ADDRESS
#Cust1
onielsen@cust1.example.com:cust1|support@cust1.example.com
kgnielsen@cust1.example.com:cust1|support@cust1.example.com
cal@example.com:cust1|support@cust1.example.com
sean@example.com:cust1|support@cust1.example.com
trevor@another.example.com:cust1|support@cust1.example.com
olganielsen@some.example.com:cust1|support@cust1.example.com
#Cust2
clark@more.example.com:cust2|gavin@cust2.example.com
gavin@more.example.com:cust2|gavin@cust2.example.com
brian@mail.example.com:cust2|gavin@cust2.example.com
#Cust3
korey@e.example.com:cust3|clint@e.example.com
scottf@e.example.com:cust3|clint@e.example.com
ront@e.example.com:cust3|clint@e.example.com
jon@e.example.com:cust3|clint@e.example.com
marshalf@e.example.com:cust3|clint@e.example.com
And then loaded them into the file like :
#!/usr/local/bin/perl
use Fcntl;
use NDBM_File;
$flatfile=“user.data”;
tie (%fdbi,‘NDBM_File’,“keyedfile”,O_CREAT|O_RDWR,0777) or die $!;
open(IN,“$flatfile”);
while () {
if($_ =~ /^#/) {
next;
}
if($_ =~ /^\s+/) {
next;
}
($key,$data)=split(/:/,$_);
$fdbi{$key}=$data;
}
close (IN);
untie %fdbi;
close(IN);
There was also some rt-mailgate, lib/RT/Action/Notify.pm
lib/RT/Interface/Email.pm changes needed, nothing big. Email me
directly for those.
Like I said, maybe with the newer version this is
obsolete.
Tuc