Mapping attributes

Hi.

I would like to know if there is some way to map users to e-mail addresses.

I use LDAP for auth and I would like that a person that send an e-mail
to RT to have permission to see that ticket. The question is that the
Requestor is the e-mail of the sender, by this reason the person that
opened the ticket is not allowed to see that ticket.

For example:
Login: test
E-mail: teste@mydomain.com
When teste@mydomain.com send an e-mail to rt@mydomain.com I want the
requestor to be test and not teste@mydomain.com

I’m using RT 3.6.1-4 debian package.

Thanks for any help.

Fabio,

I’m not completely sure what you are asking, but if you’re asking how to extract the username from the email address, we do something similar.

You can override CanonicalizeUserInfo in {RT-HOME}/local/lib/RT/User_Local.pm.


my @emailAddress = $$args{‘Name’);
my @results = split(‘@’, $emailAddress);
my $userName = $results[0];

then you want to trim the last char off…

$userName = substr($userName, 0, length($name)-1);

#Finish it up
$$args{‘Name’} = $userName;

Of course, some perl wizard could probably do that in one line using regex.

Note, that I only put the snippet to grab the username. There are examples of assigning LDAP attributes on the wiki, ExternalAuthentication - Request Tracker Wiki.

Let me know if you have any more questions.

-Craig Patterson-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of “Fábio M. Catunda”
Sent: Wednesday, February 13, 2008 8:16 AM
To: rt-users@lists.bestpractical.com
Subject: [rt-users] Mapping attributes.

Hi.

I would like to know if there is some way to map users to e-mail addresses.

I use LDAP for auth and I would like that a person that send an e-mail
to RT to have permission to see that ticket. The question is that the
Requestor is the e-mail of the sender, by this reason the person that
opened the ticket is not allowed to see that ticket.

For example:
Login: test
E-mail: teste@mydomain.com
When teste@mydomain.com send an e-mail to rt@mydomain.com I want the
requestor to be test and not teste@mydomain.com

I’m using RT 3.6.1-4 debian package.

Thanks for any help.

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Craig,

Realy thanks. I will adapt it to do a search in a LDAP base, thats
exactly wha I need.

I’m not a perl mong, but this looks pretty simple.

Thanks!

Patterson, Craig escreveu:

Well, my ultra-mega User_Local.pm realy does not work, here it is:

no warnings qw(redefine);

sub Create {
my $Email = $$args{‘Name’};
use Net::LDAP;
$ldap = Net::LDAP->new( ‘’ ) or die “$@”;
$mesg = $ldap->bind ;
$mesg = $ldap->search( attrs => [‘cn’],
scope => “sub”,
base => “ou=Users,dc=contactnet,dc=com,dc=br”,
filter => “(&(mail=$Email))” );
$mesg->code && die $mesg->error;
if ($mesg->entries){
$res = $mesg->entry(0);
$res = $res->get_value(“cn”, 1);
$$args{‘Name’} = $res;
}
$mesg = $ldap->unbind;
return 1;

};

1;

And here it goes some logging:

Mon Feb 18 22:30:23 2008] [crit]: User ‘testert@contactnet.com.br’
could not be loaded in the mail gateway
(/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:241)

Stack trace:
RT::Interface::email::MailError() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:328
RT::Interface::email::CreateUser() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email/Auth/MailFrom.pm:172
RT::Interface::email::Auth::MailFrom::GetCurrentUser() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:627
RT::Interface::email::Gateway() called at
/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:59
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0
[Mon Feb 18 22:30:23 2008] [error]: RT could not load a valid user, and
RT’s configuration does not allow
for the creation of a new user for this email (testert@contactnet.com.br).

You might need to grant ‘Everyone’ the right ‘CreateTicket’ for the
queue Suporte. (/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:241)

Stack trace:
RT::Interface::email::MailError() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:846
RT::Interface::email::_NoAuthorizedUserFound() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:652
RT::Interface::email::Gateway() called at
/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:59
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0
[Mon Feb 18 22:30:23 2008] [error]: RT could not load a valid user, and
RT’s configuration does not allow
for the creation of a new user for your email.
(/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:241)

Stack trace:
RT::Interface::email::MailError() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:859
RT::Interface::email::_NoAuthorizedUserFound() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:652
RT::Interface::email::Gateway() called at
/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:59
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0
[Mon Feb 18 22:30:23 2008] [error]: Could not record email: Could not
load a valid user
(/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:73)

Stack trace:
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0

Thanks for any help!

I’d put some debug statements in there, especially after you bind and after you search so you can isolate where it’s dying.

Craig-----Original Message-----
From: rt-users-bounces@lists.bestpractical.com [mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of “Fábio M. Catunda”
Sent: Monday, February 18, 2008 5:36 PM
To: rt-users@lists.bestpractical.com
Subject: Re: [rt-users] Mapping attributes.

Well, my ultra-mega User_Local.pm realy does not work, here it is:

no warnings qw(redefine);

sub Create {
my $Email = $$args{‘Name’};
use Net::LDAP;
$ldap = Net::LDAP->new( ‘’ ) or die “$@”;
$mesg = $ldap->bind ;
$mesg = $ldap->search( attrs => [‘cn’],
scope => “sub”,
base => “ou=Users,dc=contactnet,dc=com,dc=br”,
filter => “(&(mail=$Email))” );
$mesg->code && die $mesg->error;
if ($mesg->entries){
$res = $mesg->entry(0);
$res = $res->get_value(“cn”, 1);
$$args{‘Name’} = $res;
}
$mesg = $ldap->unbind;
return 1;

};

1;

And here it goes some logging:

Mon Feb 18 22:30:23 2008] [crit]: User ‘testert@contactnet.com.br’
could not be loaded in the mail gateway
(/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:241)

Stack trace:
RT::Interface::email::MailError() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:328
RT::Interface::email::CreateUser() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email/Auth/MailFrom.pm:172
RT::Interface::email::Auth::MailFrom::GetCurrentUser() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:627
RT::Interface::email::Gateway() called at
/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:59
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0
[Mon Feb 18 22:30:23 2008] [error]: RT could not load a valid user, and
RT’s configuration does not allow
for the creation of a new user for this email (testert@contactnet.com.br).

You might need to grant ‘Everyone’ the right ‘CreateTicket’ for the
queue Suporte. (/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:241)

Stack trace:
RT::Interface::email::MailError() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:846
RT::Interface::email::_NoAuthorizedUserFound() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:652
RT::Interface::email::Gateway() called at
/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:59
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0
[Mon Feb 18 22:30:23 2008] [error]: RT could not load a valid user, and
RT’s configuration does not allow
for the creation of a new user for your email.
(/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:241)

Stack trace:
RT::Interface::email::MailError() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:859
RT::Interface::email::_NoAuthorizedUserFound() called at
/usr/share/request-tracker3.6/lib/RT/Interface/Email.pm:652
RT::Interface::email::Gateway() called at
/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:59
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0
[Mon Feb 18 22:30:23 2008] [error]: Could not record email: Could not
load a valid user
(/usr/share/request-tracker3.6/html/REST/1.0/NoAuth/mail-gateway:73)

Stack trace:
HTML::Mason::Commands::ANON() called at
/usr/share/perl5/HTML/Mason/Component.pm:135
HTML::Mason::Component::run() called at
/usr/share/perl5/HTML/Mason/Request.pm:1251
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:1246
HTML::Mason::Request::comp() called at
/usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:460
(eval)() called at /usr/share/perl5/HTML/Mason/Request.pm:412
HTML::Mason::Request::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:165
HTML::Mason::Request::ApacheHandler::exec() called at
/usr/share/perl5/HTML/Mason/ApacheHandler.pm:832
HTML::Mason::ApacheHandler::handle_request() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
(eval)() called at
/usr/share/request-tracker3.6/libexec/webmux.pl:123
RT::Mason::handler() called at -e:0
(eval)() called at -e:0

Thanks for any help!

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Hi Craig,

I searched for

my @emailAddress = $$args{‘Name’);

inside the file that you sent me but I couldnt find. I was wondering to put my modifications at the same place. Are you sure that this is your User_Local.pm file?

Thankz!

Patterson, Craig escreveu: