开发者

JDNI Active Directory, creating groups with scope

I'm trying to create some local groups in my AD but sadly if I set a groupType attribute in my context I only receive 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 value of the attribute is wrong. Or is my issue not solveable?

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'm using Spring Ldap 1.3


Try passing the value for groupType as String not as long. This should solve your problem.

However the DN you are using looks strange. In my experience all Distinguished Names in AD ends at DC=something.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜