I am trying to create some local groups in my AD, but unfortunately, if I set the groupType attribute in my context, I get this exception
Caused by: javax.naming.directory.InvalidAttributeValueException: Malformed 'groupType' attribute value; remaining name 'cn=localTestGroup1,ou=groups' at com.sun.jndi.ldap.LdapClient.encodeAttribute(LdapClient.java:951) at com.sun.jndi.ldap.LdapClient.add(LdapClient.java:999) at com.sun.jndi.ldap.LdapCtx.c_bind(LdapCtx.java:393) at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bind(ComponentDirContext.java:277) at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(PartialCompositeDirContext.java:197) at javax.naming.directory.InitialDirContext.bind(InitialDirContext.java:163) at org.springframework.ldap.core.LdapTemplate$21.executeWithContext(LdapTemplate.java:998) at org.springframework.ldap.core.LdapTemplate.executeWithContext(LdapTemplate.java:807) ... 36 more
It is possible that the attribute value is incorrect. Or is my problem not resolved?
private void createGroup(String groupname, String groupOU, long groupType) { DistinguishedName dn = new DistinguishedName(); dn.add("ou", groupOU); dn.add("cn", groupname); DirContextAdapter ctx = new DirContextAdapter(dn); ctx.setAttributeValues("objectclass", new String[] { "top", "group" }); ctx.setAttributeValue("groupType", groupType); ctx.setAttributeValue("sAMAccountName", groupname); ldapTemplate.bind(ctx); } public void createLocalGroup(String groupname, String groupOU) { createGroup(groupname, groupOU, -2147483646); }
For claryfication: I got this value -2147483646 directly from the active directory. As you can mention, I am using Spring Ldap 1.3
source share