Hi Aliaksandr,
Thanks for quick response!
What I meant: currently we have (external) **openldap ** to store users, each user is assigned to different group (can also be common group), refer to this screenshot:
![ldap membership](https://s3.postimg.org/r3t5pdntv/membership.jpg "ldap membership")
In screenshot above, user **testkwan2 **is assigned to **SupportNetwork **group, which has a dn "cn=SupportNetwork,ou=AllGroups,ou=AllUsers,dc=example,dc=com". So what we wanted to do is retrieve this group name "SupportNetwork" (could be multiple groups) from its respective openldap properties, and assigned to every user imported from CR into Gluu.
If this could be done with custom CR script, can you please help me in getting the right code to retrieve the group name from openldap?
default CR script as follows:
```
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()
# Add new attribute preferredLanguage
attrPrefferedLanguage = GluuCustomAttribute("preferredLanguage", "en-us")
attributes.add(attrPrefferedLanguage)
# Add new attribute userPassword
attrUserPassword = GluuCustomAttribute("userPassword", "test")
attributes.add(attrUserPassword)
# Update givenName attribute
for attribute in attributes:
attrName = attribute.getName()
if (("givenname" == StringHelper.toLowerCase(attrName)) and StringHelper.isNotEmpty(attribute.getValue())):
attribute.setValue(StringHelper.removeMultipleSpaces(attribute.getValue()) + " (updated)")
return True
def getApiVersion(self):
return 1
```