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.

2 Likes

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 RT_SiteConfig.pm 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/User.pm /opt/rt4/local/lib/RT/User.pm 
*** /opt/rt4/lib/RT/User.pm	2019-03-18 10:38:50.277276621 +0000
--- /opt/rt4/local/lib/RT/User.pm	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