[jboss-user] [JBoss Portal] - Re: Can not get user role from LDAP server
saigon_man
do-not-reply at jboss.com
Mon Oct 1 15:50:26 EDT 2007
Thanks a million for the tutorials. It worked perfectly. I am now able to connect to LDAP server and retrieve the user role. Here is that I've done in case of other people would like to know how to do it
1. Follow the instructions in those tutorials above for LDAP connection
2. To retrieve user roles,
2.1 add these codes into ldap_identity-config.xml
| <option-group>
| <group-name>common</group-name>
| <option>
| <name>userCtxDN</name>
| <value>ou=People,o=test,dc=portal,dc=example,dc=com</value>
| </option>
| <option>
| <name>roleCtxDN</name>
| <value>ou=Roles,o=test,dc=portal,dc=example,dc=com</value>
| </option>
| <option>
| <name>userSearchFilter</name>
| <value><![CDATA[(uid={0})]]></value>
| </option>
| <option>
| <name>roleSearchFilter</name>
| <value><![CDATA[(cn={0})]]></value>
| </option>
| <option>
| <name>membershipAttributeID</name>
| <value>member</value>
| </option>
|
| </option-group>
|
| <module>
| <!--type used to correctly map in IdentityContext registry-->
| <type>User</type>
| <implementation>LDAP</implementation>
| <class>org.jboss.portal.identity.ldap.LDAPExtUserModuleImpl</class>
| <config/>
| </module>
| <module>
| <type>Role</type>
| <implementation>LDAP</implementation>
| <class>org.jboss.portal.identity.ldap.LDAPExtRoleModuleImpl</class>
| <config/>
| </module>
| <module>
| <type>Membership</type>
| <implementation>LDAP</implementation>
| <class>org.jboss.portal.identity.ldap.LDAPStaticGroupMembershipModuleImpl</class>
| <config/>
| </module>
|
2.2 Here are some codes that retrieve all roles associates with a specific username
| try{
| MembershipModule membershipmodule = (MembershipModule)new InitialContext().lookup("java:/portal/MembershipModule");
| User user = usermodule.findUserByUserName("Put_your_username_ here");
| Set roles = membershipmodule.getRoles(user);
| Iterator iter = roles.iterator();
| while(iter.hasNext()){
| role = (Role)iter.next();
| System.out.println("Role: " + role.getDisplayName());
|
| }
| }catch(Exception e){
| // Do something here
| }
|
SGM
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4090396#4090396
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4090396
More information about the jboss-user
mailing list