File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Products » Websphere
Bookmark "Add user to ldap groups!!" Watch "Add user to ldap groups!!" New topic

Add user to ldap groups!!

Ashok Mudgapalli

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?
David O'Meara

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.
David O'Meara

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:

I agree. Here's the link:
subject: Add user to ldap groups!!
It's not a secret anymore!