[rt-devel] logging LDAPImport in Transactions table

Parish, Brent bparish at cognex.com
Tue Nov 10 09:16:52 EST 2015


We use LDAPImport to update RT User values from Active Directory.

In our Active Directory, some of the addresses and other fields have odd characters in them and/or multiple lines (return characters), mostly from non-U.S. addresses.

The LDAPImport registers these fields as 'changed' even when they have not, and this logs over 7,500 entries in the Transactions table per month for us (only running LDAPImport twice a day).
(please note that this is not a 'fault' specific to LDAPImport.  Even when changing a different field in a User's account (via the browser based interface), RT thinks the address field changed when it has funky characters or spans multiple lines)

Since the LDAP values clobber the RT fields, I don't really care to log the transactions (especially when there are so many). 
So I decided to avoid logging all changes to the Transactions table during the LDAPImport, only logging them when they are set via the browser.

I don't know if this affects anyone else or not, but if it is helpful, this is what we are doing about it.


First I added a setting in RT_SiteConfig.pm 
	Set($DontRecordLDAPImport, 1);

And then this minor change to User.pm (per standard RT modification rules - copy to local/lib/RT before changing it!)
Note that this is pulled from 4.4.0RC1, so the line numbers may be different in other versions.

# diff -wU12 lib/RT/User.pm local/lib/RT/User.pm
--- lib/RT/User.pm	2015-11-10 09:01:32.739886637 -0500
+++ local/lib/RT/User.pm	2015-11-10 09:13:33.687537889 -0500
@@ -1653,24 +1653,26 @@
 sub _Set {
     my $self = shift;
     my %args = (
         Field => undef,
         Value => undef,
     TransactionType   => 'Set',
     RecordTransaction => 1,
+    $args{RecordTransaction} = 0 if ( (caller(4))[3] =~ m/LDAPImport/ && $RT::DontRecordLDAPImport );


Even though User based custom fields weren't really an issue for me (didn't contain the same characters that were causing so many Transaction table entries), for completeness I also modified Record.pm to not write changes (from LDAPImport) into the Transaction table for user based custom field changes.

# diff -wU12 lib/RT/Record.pm local/lib/RT/Record.pm
--- lib/RT/Record.pm	2015-11-10 09:01:39.491696253 -0500
+++ local/lib/RT/Record.pm	2015-11-10 08:50:12.938925672 -0500
@@ -1931,24 +1931,26 @@
 sub _AddCustomFieldValue {
     my $self = shift;
     my %args = (
         Field             => undef,
         Value             => undef,
         LargeContent      => undef,
         ContentType       => undef,
         RecordTransaction => 1,
+    $args{RecordTransaction} = 0 if ( (caller(4))[3] =~ m/LDAPImport/ && $RT::DontRecordLDAPImport );

More information about the rt-devel mailing list