[rt-users] Filling in custom fields from LDAP

Michael Ellis michael_ellis at umanitoba.ca
Fri Mar 12 11:18:44 EST 2010


There's actually an example of how to do just this in the book.

Here's mine:

      my $email = ($self->TicketObj->RequestorAddresses)[0];
        
        my $ldap = Net::LDAP->new( 'ldap.somewhere.com' );
        $ldap->bind;
        
        my $msg = $ldap->search( base   => 'o=XXXXXXXXXX,c=YY',
                                 filter => "(mail=$email)",
                               );
        
        my $entry = $msg->entry(0);
        
        my $phone= $entry->get_value('telephoneNumber');
        my $cf = RT::CustomField->new( $RT::SystemUser );
       
        $cf->LoadByName( Name => 'RequestorPhone' );
       
        $self->TicketObj->AddCustomFieldValue( Field => $cf, Value =>
    $phone, RecordTransaction => 0);

        return 1;


-Mike

Mike Peachey wrote:
> Jeff Blaine wrote:
>   
>> I'm looking to fill in custom fields with data retrieved
>> from an LDAP server.
>>
>> That is, someone with permission to modify an existing
>> ticket will enter some data into a custom field, then
>> save the modification.  At save time, the code will
>> use that custom field to populate another custom field
>> with LDAP query results.
>>
>> Would this best be done as a plugin?  A Scrip?  Other?
>>     
>
> You will need a scrip to do it. I'm not aware of any plugin currently
> available that could do it for you.
>
> The basics of the scrip shouldn't be too hard, but you're going to need
> to set up an LDAP connection, do a valid search, parse the results save
> the results etc. There is LDAP code for RT in the ExternalAuth plugin
> that may be useful for copying and pasting, but I don't envy you your task.
>
>   

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20100312/a9f5b1e3/attachment.htm>


More information about the rt-users mailing list