DirContext ctx = LDAPUserManager.bindAsAdmin();
// Make the attributes.
Attributes attrs = new BasicAttributes();
attrs.put(new BasicAttribute("turbineRoleName", roleName));
attrs.put(new BasicAttribute("objectClass", "turbineUserGroup"));
attrs.put(new BasicAttribute("turbineUserUniqueId", userName));
try
{
// Add the turbineUserGroup.
ctx.bind(dn, null, attrs);
}
catch (NameAlreadyBoundException ex)
{
// Since turbineUserGroup had already been created
// then just add the role name attribute.
attrs = new BasicAttributes();
attrs.put(new BasicAttribute("turbineRoleName", roleName));
ctx.modifyAttributes(dn, DirContext.ADD_ATTRIBUTE, attrs);
}
}
catch (NamingException ex)