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

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

        <legend id='GsBBl'><style id='GsBBl'><dir id='GsBBl'><q id='GsBBl'></q></dir></style></legend>

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

        Java、LDAP:让它不忽略空白密码?

        时间:2024-05-10
              <tbody id='BIXXB'></tbody>

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

                <tfoot id='BIXXB'></tfoot>
              1. <legend id='BIXXB'><style id='BIXXB'><dir id='BIXXB'><q id='BIXXB'></q></dir></style></legend>

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

                • <bdo id='BIXXB'></bdo><ul id='BIXXB'></ul>
                  本文介绍了Java、LDAP:让它不忽略空白密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在维护一些旧版 Java LDAP 代码.我对 LDAP 几乎一无所知.

                  I'm maintaining some legacy Java LDAP code. I know next to nothing about LDAP.

                  下面的程序基本上只是将用户名和密码发送到 LDAP 服务器,如果凭据正确,则会收到通知.如果是,则打印出从 LDAP 服务器接收到的 LDAP 属性,如果不是,则打印出异常.

                  The program below basically just sends the userid and password to the LDAP server, receives notification back if the credentials are good. If so, it prints out the LDAP attributes received from the LDAP server, if not it prints out an exception.

                  如果输入的密码错误,一切正常.抛出无效凭据"异常.但是,如果向 LDAP 服务器发送空白密码,仍然会进行身份验证,仍然会返回 LDAP 属性.

                  All works well if a bad password is given. An "invalid credentials" exception gets thrown. However, if a blank password is sent to the LDAP Server, authentication will still happen, LDAP attributes will still be returned.

                  这种不愉快的情况是由于 LDAP 服务器允许空白密码,还是需要调整下面的代码,这样空白密码才会以这种方式输入 LDAP 服务器而被拒绝?

                  Is this unhappy situation due to the LDAP server allowing blank passwords, or does the code below need to be adjusted such a blank password will get fed to the LDAP server in such a way so it will get rejected?

                  我确实有数据验证.我在测试环境中将其取下来解决另一个问题并注意到了这个问题.我不希望在数据验证下出现这个问题.

                  I do have data validation in place. I took it off in a testing environment to solve another issue and noticed this problem. I would prefer not to have this problem underneath the data validation.

                  非常感谢您提供任何信息

                  Thanks much in advance for any information

                  import javax.naming.*;
                  import javax.naming.directory.*;
                  import java.util.*;
                  import java.sql.*;
                  
                  public class LDAPTEST {
                  
                      public static void main(String args[]) {
                  
                          String lcf                = "com.sun.jndi.ldap.LdapCtxFactory";
                          String ldapurl            = "ldaps://ldap-cit.smew.acme.com:636/o=acme.com";
                          String loginid            = "George.Jetson";
                          String password           = "";
                          DirContext ctx            = null;
                          Hashtable env             = new Hashtable();
                          Attributes attr           = null;
                          Attributes resultsAttrs   = null;
                          SearchResult result       = null;
                          NamingEnumeration results = null;
                          int iResults              = 0;
                          int iAttributes           = 0;
                  
                  
                          env.put(Context.INITIAL_CONTEXT_FACTORY, lcf);
                          env.put(Context.PROVIDER_URL, ldapurl);
                          env.put(Context.SECURITY_PROTOCOL, "ssl");
                          env.put(Context.SECURITY_AUTHENTICATION, "simple");
                          env.put(Context.SECURITY_PRINCIPAL, "uid=" + loginid + ",ou=People,o=acme.com");
                          env.put(Context.SECURITY_CREDENTIALS, password);
                          try {
                  
                              ctx     = new InitialDirContext(env);
                              attr    = new BasicAttributes(true);
                              attr.put(new BasicAttribute("uid",loginid));
                              results = ctx.search("ou=People",attr);
                  
                              while (results.hasMore()) {
                                  result       = (SearchResult)results.next();
                                  resultsAttrs = result.getAttributes();
                  
                                  for (NamingEnumeration enumAttributes  = resultsAttrs.getAll(); enumAttributes.hasMore();) {
                                      Attribute a = (Attribute)enumAttributes.next();
                                      System.out.println("attribute: " + a.getID() + " : " + a.get().toString());
                                      iAttributes++;
                  
                  
                                  }// end for loop
                  
                                  iResults++;
                              }// end while loop
                  
                              System.out.println("Records  == " + iResults + " Attributes: " + iAttributes);
                  
                          }// end try
                          catch (Exception e) {
                              e.printStackTrace();
                          }
                  
                  
                  
                      }// end function main()
                  }// end class LDAPTEST
                  

                  推荐答案

                  很遗憾,使用 DN 和空密码进行身份验证是 LDAP 的难点之一,会导致未经身份验证".来自服务器的积极响应.一些 LDAP 服务器有配置选项来禁用在最新版本的 LDAPv3 (RFC 4511) 中不鼓励的行为,甚至默认禁用它.

                  Unfortunately, the authentication with a DN and an empty password is one of the difficiency of LDAP, and results in an "unauthenticated" positive response from the server. Some LDAP servers have configuration options to disable that behavior that has been discouraged in the latest revision of LDAPv3 (RFC 4511), and even have it disabled by default.

                  最终,客户端应用程序应该检查输入参数并确保密码不为空.

                  Ultimately, the client application should check input parameters and make sure the password is not empty.

                  这篇关于Java、LDAP:让它不忽略空白密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将 AD 组映射到用户角色 Spring Security LDAP 下一篇:从 Java 应用程序连接 LDAP 服务器

                  相关文章

                    <bdo id='USWfj'></bdo><ul id='USWfj'></ul>
                • <small id='USWfj'></small><noframes id='USWfj'>

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

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

                    <legend id='USWfj'><style id='USWfj'><dir id='USWfj'><q id='USWfj'></q></dir></style></legend>