A case study of implementing custom User Import module for Liferay
Tue, 03/09/2010 - 00:37 | by advait.trivedi@...
Context
“Bringing” users from an external Active Directory server or any other directory server supporting LDAP for that matter is a common requirement of almost all portal solutions. That’s the exact reason Liferay has addressed this requirement out of the box (OOB). But in a several cases, business specific rules are involved in user import activity. Which makes it appropriate to go for custom User Import module.
Liferay exposes a set of API, which is as rich as you’ll need to import users from external directory server. This article is outcome of a successfully implemented User Import module for a client. And contains suggestions which can keep one from falling in to same pitfalls. On the other hand, it is as “high level” as possible so implementers can design as they choose.
Divide and Conquer
Considering Active Directory server as your LDAP source lets break the problem of User Import into parts.
Reading users from LDAP
Searching directory Server using LDAP
LDAP stands for Light weight Directory Access Protocol. It defines an inter-operable standard API for applications to communicate with Directory Servers. Java’s support and API for LDAP is commonly referred to as Java Naming and Directory Interface (JNDI). See http://java.sun.com/products/jndi/ for more info.
Consider these points when searching a Directory using JNDI:
* Consider using connection pool when creating Context
* Utilize JNDI’s search features. Provide filters and controls to narrow the search result and page the search results. You can learn about Search filters at http://java.sun.com/products/jndi/tutorial/basics/directory/filter.html. Active Directory has support for Paged result set. You can learn about Paged Results at http://java.sun.com/docs/books/tutorial/jndi/newstuff/paged-results.html.
* Trade-off between page-size of search results. The lesser the page-size the more number of pages and hence more requests to server, but faster response from server. The more the page-size less number of pages and hence less requests to server, but slower response from server. Typically, page size of 100 is used.
* Keep pool-size and page-size configurable, and same for all other connection parameters like, credentials, Server address etc.
Creating User objects
Part of the challenge is to create a User object, which is akin to users in Liferay, i.e., users having identical attributes to Liferay’s users. This will take away many complexities. Consider creating an attribute mapper utility for this. And input to this utility should be configurable. At the simplest maintain a comma-separated list somewhere,
ldapattrib1=liferayattrib1,ldapattrib2=liferayattrib2,…..,ldapattribn=liferayattribn
Got a new attribute? Add to the above list, mapper utility reloads the mapping & you are good to go!
Similarly, if you are planning to update/insert users with roles and organizations membership info, have a mapping for them as well.
Custom Attributes
Consider using Liferay’s Custom User Attributes when corresponding attribute of LDAP is not available in Liferay OOB. Not only they serve the purpose, more of them can be added without a single bit of coding!! Custom attribute is a must know for any Liferay project implementer. Explore Liferay’s “Control Panel > Users > Custom Attributes” section to learn more.
Importing Users to Liferay
Try to abstract away details of implementation that reads users from LDAP. Import user should ideally be only concerned about adding/updating users to Liferay. It is not in interest of import service to know where users are coming from. This way you can easily reuse the same code for some other source of users, e.g. a database.
Liferay exposes a set API for working with Users. The exposed API is mostly consistent between local version and remote version (which is exposed as Web Service).
Important Liferay APIs
*
UserSerivceSoap: Allows you to perform operations such as add, update, activate, deactivate Users
*
GroupServiceSoap: Important service for getting organizational group for users
*
RoleSerivceSoap: Important for getting organizational or group roles for users
*
UserGroupRoleServiceSoap: If you want to assign a user an organization role, this is the service for you
*
ExpandoValueServiceSoap: Use this service to add value of a custom attribute
To learn more about Groups, Roles, Organization see Liferay Admin Guide at http://www.liferay.com/documentation/5.2
If you are interested in what all WebServices are exposed, open this URL of your Liferay server: http://localhost:8080/tunnel-web/secure/axis/
Retrieving SOAP service instances
Handle to Liferay exposed WebSservice is retrieved through Locators implemented by Liferay. An example to get GroupServiceSoap will be:
new GroupServiceSoapServiceLocator().getPortal_GroupService("http://10144:test@localhost:8090/tunnel-web/secure/axis/Portal_GroupService");
Similarly you can user service specific locator and get server instances of all the services listed in above section. Also notice that, Liferay API works on user Id (10144, in above e.g.) rather than user name.
Consider Update implications
It is very likely that after User Import module is done importing users, it will be required to update user information of existing users if LDAP server has some updated information for that user. This can lead to unwanted surprises. Take an example of a User, which was imported by the custom import module. Now, administrator assigns some roles to this user manually through Liferay Control Panel. Next time the module runs it overwrites this information with information coming from LDAP!! To handle this, clearly specify and conclude which attributes are additive in nature and which are overwritten. Attributes such as Role membership, Organization membership, Organization Role membership can be additive. To implement additive updates, pre-read the user’s attribute values from Liferay and create a composite set of values that contain both LDAP and Liferay values for that attribute. Call the update service with this composite set of values for that attribute.
Scheduling
Even though not a must, scheduling can take away pains of an administrator by automatically triggering import jobs at desired time. Open source scheduling frameworks like Quartz are enterprise ready. Quartz also recognizes Unix cron job syntax. To learn Quartz visit http://www.quartz-scheduler.org/docs/tutorial/.
Summary
User Import is one module that has high chances of getting reused in your organization. So it should be kept as configurable as possible and as modularized as possible. Also, consider issues like time required to complete a run of module, because this is the period when Directory Server and Liferay will be out of sync.
Advait Trivedi,
Prinicipal Consultant,
CIGNEX India Office
相关推荐
数据挖掘实战:决策树 + 聚类 + 关联规则,零 Key 离线可跑(Python 源码)
数据挖掘实战包。用 Python 标准库实现 CART 风格决策树、K-Means 聚类与 Apriori 关联规则,在虚构「星河便利店」会员表和购物篮上跑通分类、分群与购物篮分析,并给出准确率、轮廓系数、支持度/置信度/提升度。零第三方依赖、零 API Key 即可离线跑通。含 4 个样例、离线冒烟、中文 README(含「使用方法」)。均为作者原创可运行源码。MIT。作者 blog.youkuaiyun.com/mtl1994
产业园区运营负责人如何利用平台实现企业创新需求的精准分析与服务推送?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
科技中介服务机构在技术供需对接中如何实现服务流程的自动化与标准化?.docx
科技中介服务机构在技术供需对接中如何实现服务流程的自动化与标准化?
高校技术转移办公室人员在推动成果转化落地过程中,如何实现科技成果的高效推介与价值评估?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
产业园区如何高效对接企业技术需求与高校科研成果?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
国央企创新负责人如何快速掌握本地科技资源分布与匹配情况?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
科技中介服务机构如何通过数智工具提升技术需求挖掘的精准度?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
国央企创新负责人如何实现科技成果的精准识别与高效筛选?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
政府科技管理者如何在政策支持中更精准地识别和支持高价值科技项目?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
高校技术转移办公室人员如何系统化管理科技成果信息?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
科技中介服务机构如何构建标准化、模块化的智能服务工具?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
全桥LLC谐振变化器参数设计资料(闭环仿真+参数设计报告)
内容概要:本文档系统性地介绍了全桥LLC谐振变换器的闭环仿真建模与关键参数设计方法,涵盖其工作原理、谐振元件(如谐振电感、谐振电容、励磁电感)的计算与优化流程,并结合Simulink或Plecs等仿真平台构建闭环控制系统模型,重点验证变频控制策略下的软开关实现、系统增益特性、效率优化及动态响应性能。资料包含完整的仿真模型、参数设计报告、数学计算书及参考文献,支持从理论分析到工程实践的全流程研究,适用于高频高效DC-DC变换器的研发与教学应用。; 适合人群:电力电子、电气工程及其自动化等相关专业的高校学生、科研人员,以及从事开关电源、新能源变换器、工业电源研发的工程技术人员,具备电路拓扑基础与仿真软件操作能力者更佳。; 使用场景及目标:①深入掌握全桥LLC谐振变换器的工作机理与谐振参数设计准则;②学习并实现闭环反馈控制系统的建模与稳定性分析;③支撑科研课题、课程设计、毕业设计或实际产品开发中的拓扑选型与性能验证需求;④通过仿真与计算联动提升对软开关技术与效率优化的理解与应用能力。; 阅读建议:建议结合所提供的仿真文件与设计文档同步操作,按照“建模—参数计算—仿真验证—性能分析”的流程逐步推进,重点关注频率调节对ZVS/ZCS实现的影响,对比不同负载条件下的闭环响应差异,深化对谐振腔特性和控制策略协同作用的理解。
fab-pm-optimizer-python-entry-py39-20261021-v1-1-0
fab-pm-optimizer-python-entry-py39-20261021-v1-1-0
政府科技管理者如何提升区域科技成果转化项目的评价与筛选效率?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
PSIM-三相维也纳VIENNA整流器电压电流双闭环+中点电位平衡SVPWM控制仿真
内容概要:本文档详细介绍了一种基于PSIM软件实现的三相维也纳(VIENNA)整流器仿真模型,重点实现了电压电流双闭环控制与中点电位平衡的SVPWM调制策略。该仿真系统通过精确的控制算法有效提升了整流器的功率因数,降低了输入电流谐波含量,并解决了三电平拓扑中常见的直流侧中点电位偏移问题,具有较高的工程实用价值,适用于高效率、高功率密度的电力电子系统设计与科研验证。文档还整合了丰富的配套资源,涵盖多种电力电子变换器拓扑结构、先进控制算法及典型应用场景,形成了系统化的技术资料体系,有助于深入理解现代整流技术的核心原理与发展动态。; 适合人群:面向从事电力电子、电气工程、新能源变换系统等领域的科研人员、高校研究生以及具备一定仿真基础的工程技术人员。; 使用场景及目标:①深入研究三相VIENNA整流器的工作机理与控制特性;②掌握电压外环、电流内环双闭环控制结构的设计方法;③理解并实现SVPWM调制技术与中点电位平衡控制策略的协同作用;④开展相关控制算法的仿真验证、性能优化与实验对比,为高性能整流装置的研发提供理论支撑和技术原型。; 阅读建议:建议结合文中列出的其他仿真案例(如PWM整流器、LLC谐振变换器、DAB变换器等)进行横向对比学习,充分利用所提供的PSIM、MATLAB/Simulink等多平台仿真资源,重点关注控制逻辑与主电路的耦合关系,通过参数调试与波形分析深化对系统动态响应和稳态性能的理解,强化“理论—建模—仿真—优化”的闭环研究能力。
产业园区运营负责人如何利用数智工具提升园区企业的技术对接效率?.docx
科易网基于AI模型+行业大数据,在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,推出科技创新领域的AI+工具与数智化解决方案,推动科技创新与产业创新智能化发展。
jp-host-release.apk
jp-host-release.apk
ICD10 openGauss版
ICD10 openGauss版



被折叠的 条评论
为什么被折叠?



