Searching user custom field in RT 4.4.x

As part of expanding our RT usage here we’ve been asked by a user department if we could bring extra information from our Active Directory user records into RT and make that information available to RT TicketSQL searches. We’ve done some work on this and thought a few other RT admins might find the tweaks that we’ve made to support this useful, so here’s a blog post about this.

It’s a bit “niche” but it might help point other folk in the right direction, and its also an example of how RT’s callbacks and local overlays can be used in anger.


Thanks a really well written article!

Found a little gotcha (and a fix!):

When creating new users via LDAP we were getting failures logged. Looking into it, it appears that the RT::User Create() method doesn’t understand about ‘UserCF.*’ fields from the which rt-ldapimport passes into it. Thus updating users that already existed in RT worked fine, but new users wouldn’t be created. A quick fix is to pop this patch into the Create() method of RT::User:

# diff -c /opt/rt4/lib/RT/ /opt/rt4/local/lib/RT/ 
*** /opt/rt4/lib/RT/	2019-03-18 10:38:50.277276621 +0000
--- /opt/rt4/local/lib/RT/	2020-02-12 10:29:55.512468977 +0000
*** 185,190 ****
--- 185,195 ----
      delete $args{'Disabled'};
+     foreach my  $thisArg (keys %args) {
+         next if($thisArg !~ /^UserCF\./);
+         delete $args{$thisArg};
+     }
      $self->SUPER::Create(id => $principal_id , %args);
      my $id = $self->Id;

What this does is remove all UserCF.* arguments being passed into create before it calls the SUPER::Create() method. This allows the user object to be created successfully, and rt-ldapimport then updates the custom fields correctly. Phew!

1 Like

I was just wondering if someone had tried to reproduce the blog function. I added it for one of our user custom fields but the customfield does not appear in the Query Builder for use. Any ideas?


CF won’t appear in Query builder unless you first add the queue in which it is applied. But it’s searchable in manual query.