Message Boards

Problems getting accurate usermodifieddate.

Antony Potter, modified 16 Years ago.

Problems getting accurate usermodifieddate.

New Member Posts: 8 Join Date: 10/9/07 Recent Posts
Hi,

I'm having problems finding out programtically when a user account was last modified.

Just to give some background, we have an LDAP directory that we use to hold user information and we use this as a source for most of the user information in our Liferay set up. We're not using the Liferay supplied LDAP scripts, as for reasons I won't go into, we don't implement LDAP groups in the standard way. So I've written an AutoLogin plugin that runs against our directory and updates Liferay user information and groups accordingly. That bit works just fine.

However that runs everytime a user logs in. I'd like to only run it if the user object in the directory has been updated more recently than Liferay. I'm using the utility classes UserGroupLocalServiceUtil and UserLocalServiceUtil to update user properties but doing this doesn't update the modifieddate value of the user. Even running user.setModifiedDate() after the modifications doesn't change its value.

I think this should work, but can't see why it isn't...


User user = UserLocalServiceUtil.getUserByScreenName(companyId, screenName);

// Get the modified date from LDAP
Date cdModDate = ESSLDAPUtil.getCDLastModified(companyId, screenName);

// Get the modified date from Liferay
Date portalModDate = user.getModifiedDate();


if ( portalModDate.before( cdModDate ) ){
// Run code to update Liferay from directory...
...

user.setModifiedDate( new Date( System.currentTimeMillis() ) );
}



I've been struggling with this for a couple of days now, so any help would be much appreciated.

Thanks in advance

Tony