<small id='eR9mV'></small><noframes id='eR9mV'>

    <legend id='eR9mV'><style id='eR9mV'><dir id='eR9mV'><q id='eR9mV'></q></dir></style></legend>
    1. <i id='eR9mV'><tr id='eR9mV'><dt id='eR9mV'><q id='eR9mV'><span id='eR9mV'><b id='eR9mV'><form id='eR9mV'><ins id='eR9mV'></ins><ul id='eR9mV'></ul><sub id='eR9mV'></sub></form><legend id='eR9mV'></legend><bdo id='eR9mV'><pre id='eR9mV'><center id='eR9mV'></center></pre></bdo></b><th id='eR9mV'></th></span></q></dt></tr></i><div id='eR9mV'><tfoot id='eR9mV'></tfoot><dl id='eR9mV'><fieldset id='eR9mV'></fieldset></dl></div>

          <bdo id='eR9mV'></bdo><ul id='eR9mV'></ul>

        <tfoot id='eR9mV'></tfoot>

        使用 Java 将 Ldap 用户与组关联

        Associate Ldap user to a group with Java(使用 Java 将 Ldap 用户与组关联)

      1. <small id='1VnGr'></small><noframes id='1VnGr'>

          • <bdo id='1VnGr'></bdo><ul id='1VnGr'></ul>
              <tbody id='1VnGr'></tbody>
            <legend id='1VnGr'><style id='1VnGr'><dir id='1VnGr'><q id='1VnGr'></q></dir></style></legend>

            1. <tfoot id='1VnGr'></tfoot>

                <i id='1VnGr'><tr id='1VnGr'><dt id='1VnGr'><q id='1VnGr'><span id='1VnGr'><b id='1VnGr'><form id='1VnGr'><ins id='1VnGr'></ins><ul id='1VnGr'></ul><sub id='1VnGr'></sub></form><legend id='1VnGr'></legend><bdo id='1VnGr'><pre id='1VnGr'><center id='1VnGr'></center></pre></bdo></b><th id='1VnGr'></th></span></q></dt></tr></i><div id='1VnGr'><tfoot id='1VnGr'></tfoot><dl id='1VnGr'><fieldset id='1VnGr'></fieldset></dl></div>
                • 本文介绍了使用 Java 将 Ldap 用户与组关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在查找如何将 #Ldap 用户与给定组关联时遇到问题.

                  I'm having problems to find how to associate a #Ldap user to a given group.

                  这是我尝试过的:

                      Attributes attrs = new BasicAttributes();
                  
                      BasicAttribute basicAttrs = new BasicAttribute("objectclass");
                      basicAttrs.add("top");
                      basicAttrs.add("person");
                  
                      BasicAttribute memberOf = new BasicAttribute("memberOf");
                      memberOf.add("Managers"); // Tried with distinguished name too
                      memberOf.add("Administrators"); // Tried with distinguished name too
                  
                      attrs.put(basicAttrs);
                      attrs.put("cn", user.getLogin());
                      attrs.put("name", user.getLogin());
                      attrs.put("login", user.getLogin());
                      attrs.put("mail", user.getMail());
                      attrs.put("displayName", user.getDisplayName());
                      attrs.put("memberOf", memberOf);
                  
                      try {
                          ctx.bind("CN=" + user.getLogin() + "," + baseDn, null, attrs);
                      } catch (NamingException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                      }
                  

                  我还尝试使用专有名称,例如:CN=Managers,OU=,OU=Users,OU=,DC=com",但没有奏效.我认为它应该在某个地方引用 Ldap 组.

                  I also tried to use the distinguished names like: "CN=Managers,OU=<system_name>,OU=Users,OU=<server>,DC=com", but didn't work. I think it should be somewhere to reference the Ldap group.

                  但是我收到了这个错误:

                  But I got this error:

                  javax.naming.directory.InvalidAttributeValueException: Malformed 'memberOf' attribute value; remaining name 'CN=lcarvalho,OU=<system_name>,OU=Users,OU=<server>,DC=com'
                  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:396)
                  at com.sun.jndi.toolkit.ctx.ComponentDirContext.p_bind(ComponentDirContext.java:277)
                  at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(PartialCompositeDirContext.java:197)
                  at com.sun.jndi.toolkit.ctx.PartialCompositeDirContext.bind(PartialCompositeDirContext.java:186)
                  at javax.naming.directory.InitialDirContext.bind(InitialDirContext.java:158)
                  ...
                  

                  这是除了我的应用程序行之外的所有堆栈跟踪.

                  This is all the stack trace besides my application lines.

                  推荐答案

                  如果您使用 OpenLDAP,memberOf 属性由 memberOf 覆盖自动维护,您的应用程序根本不应该写它.您应该做的是将用户的 DN 添加到他加入的组的 uniqueMemberroleOccupant 等属性中.然后它的 DN 会神奇地出现在他的 memberOf 属性中.

                  If you're using OpenLDAP the memberOf attribute is maintained automatically by the memberOf overlay, and your application shouldn't write it at all. What you should be doing is adding the DN of the user to the uniqueMember or roleOccupant etc. attribute of the group he is joining. Then its DN will magically appear in his memberOf attribute.

                  这篇关于使用 Java 将 Ldap 用户与组关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  • <bdo id='TKJJ2'></bdo><ul id='TKJJ2'></ul>

                    1. <i id='TKJJ2'><tr id='TKJJ2'><dt id='TKJJ2'><q id='TKJJ2'><span id='TKJJ2'><b id='TKJJ2'><form id='TKJJ2'><ins id='TKJJ2'></ins><ul id='TKJJ2'></ul><sub id='TKJJ2'></sub></form><legend id='TKJJ2'></legend><bdo id='TKJJ2'><pre id='TKJJ2'><center id='TKJJ2'></center></pre></bdo></b><th id='TKJJ2'></th></span></q></dt></tr></i><div id='TKJJ2'><tfoot id='TKJJ2'></tfoot><dl id='TKJJ2'><fieldset id='TKJJ2'></fieldset></dl></div>

                      <small id='TKJJ2'></small><noframes id='TKJJ2'>

                          <tbody id='TKJJ2'></tbody>
                      • <legend id='TKJJ2'><style id='TKJJ2'><dir id='TKJJ2'><q id='TKJJ2'></q></dir></style></legend>

                          1. <tfoot id='TKJJ2'></tfoot>