We have been trying to add users to groups using JNDI. Our directory server is Active Directory on Windows 2003.
We were able to create users and groups just fine. However, making these users part of any group is a problem. Here is what the code looks like (inspired by this):
ModificationItem mod[] = new ModificationItem[1];
mod[0] = new ModificationItem(DirContext.ADD_ATTRIBUTE,
new BasicAttribute("member", "CN=User1,OU=LocationOfUser"));
localcontext.modifyAttributes("CN=Group1,ou=Group,ou=LocationOfTheGroup", mod);
We get this error back:
javax.naming.NameNotFoundException: [LDAP: error code 32 - 00000525:
NameErr: DSID- 031A0F80, problem 2001 (NO_OBJECT), data 0, best match of: ''
We have tried to bind to a subroot (and not give the full DN in the attributes) or binding to the root (and giving the full DN in the attributes).
EDIT: We tried the same code, but with a user in the Users CN (CN=abcd,CN=Users
), and it works!!! But how come it won't allow it for users outside of that?