Try to use this, it works for me
ModificationItem[] mods = new ModificationItem[1];
String userDn="cn=user name,CN=Users,DC=domain,DC=com"
String groupDn="cn=Group Name,CN=Groups,DC=domain,DC=com"
Attribute mod =new BasicAttribute("member",userDn);
mods[0] =new ModificationItem(DirContext.ADD_ATTRIBUTE, mod);
ldapContext.modifyAttributes(groupDn, mods);