wood burning stoves 2.0*
The moose likes Websphere and the fly likes Add user to ldap groups!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "Add user to ldap groups!!" Watch "Add user to ldap groups!!" New topic
Author

Add user to ldap groups!!

Ashok Mudgapalli
Greenhorn

Joined: Jun 24, 2003
Posts: 13
I am new to ldap. How do I add a user to a particular group in ldap? I am using IBM ldap and my admin had created several groups to which I need to add users programatically. Can any one tell me how to do this?
Thanks!
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Do you have access to the SecureWay client? If not, you will need access to either this or another LDAP client. You could do it using JNDI, but the client is generally easier.
You also need to know the name of the LDAP role and the DN (ie full distinctive name) of the person you want to add to the role.
Connect to the client, find the role, add the entry.
If you don't have the full DN for the role, you can seach using cn=name_of_role and still able to add the user. You can find the DN of the user in the same way.
This is sometimes confusing, since you add users to the role entry, rather than adding the role entry to the user. But that's the way it works.
Hope this helps.
Dave.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Oops, my bad, I missed the past "add users programatically".
The code I use is listed below

Note that the group type we use is objecttype=groupofnames, which stores users as "member" (see the ModificationItem). If you use a different objecttype you will need to add the correct attribute.
For no extra cost, here is the remove code:

Dave
 
Consider Paul's rocket mass heater.
 
subject: Add user to ldap groups!!
 
Similar Threads
questions regarding LDAP repository & Websphere
Add user to a group!!
Application Security with LDAP
LDAP : creation of users, groups etc
best practice for authentication and role assignation.