By: Rajesh Anandarajan user 03 Apr 2021 at 12:57 a.m. CDT

1 Response
Rajesh Anandarajan gravatar
Trying to do a cache refresh from a zimbra email ldap. there the zimbraAccountStatus is "closed" instead of glueeStatus "inactive". how do i map value based on condition. Status active is same in zimbra and gluu

By Rajesh Anandarajan user 03 Apr 2021 at 11:15 a.m. CDT

Rajesh Anandarajan gravatar
i was able to figure that out. My script was working except it was not updating the fields since it was already being cached. When i added a new field to cache, it ran and update all fields and hence the script was able to do update the value on an if condition. Is there a better option? I will quote my script below., Also is there a way to refresh the cached value from scratch rather than to add / pull a new field? Not sure what is not needed from the below script otherthan all the prints. ## **Script** from org.xdi.model.custom.script.type.user import CacheRefreshType from org.xdi.util import StringHelper, ArrayHelper from java.util import Arrays, ArrayList from org.gluu.oxtrust.model import GluuCustomAttribute import java class CacheRefresh(CacheRefreshType): def __init__(self, currentTimeMillis): self.currentTimeMillis = currentTimeMillis def init(self, configurationAttributes): print "Cache refresh. Initialization" print "Cache refresh. Initialized successfully" return True def destroy(self, configurationAttributes): print "Cache refresh. Destroy" print "Cache refresh. Destroyed successfully" return True # Update user entry before persist it # user is org.gluu.oxtrust.model.GluuCustomPerson # configurationAttributes is java.util.Map<String, SimpleCustomProperty> def updateUser(self, user, configurationAttributes): print "Cache refresh. UpdateUser method" attributes = user.getCustomAttributes() # Update givenName attribute for attribute in attributes: attrName = attribute.getName() print "attrName " + attrName + " attrValue " + attribute.getValue() if (("gluustatus" == StringHelper.toLowerCase(attrName)) and ("closed" == StringHelper.toLowerCase(attribute.getValue()))): attribute.setValue("inactive") print "attrName " + attrName + " attrValue " + attribute.getValue() return True def getApiVersion(self): return 1