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

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

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

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

      2. 如何通过 JNDI 检索 LDAP 密码

        How to retrieve LDAP password via JNDI(如何通过 JNDI 检索 LDAP 密码)

            1. <legend id='6p8pM'><style id='6p8pM'><dir id='6p8pM'><q id='6p8pM'></q></dir></style></legend>
            2. <small id='6p8pM'></small><noframes id='6p8pM'>

                <tbody id='6p8pM'></tbody>

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

              • <tfoot id='6p8pM'></tfoot>
                • <bdo id='6p8pM'></bdo><ul id='6p8pM'></ul>
                  本文介绍了如何通过 JNDI 检索 LDAP 密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我可以通过 JNDI 读取存储在 LDAP 中的密码.但结果是一些乱码.那么如何解密呢?

                  I am able to read the password stored in LDAP via JNDI. But the result is some gibberish characters. So how do i decrypt it?

                  下面是我的代码:

                  public static void main(String[] args)
                          {
                              String INITCTX = "com.sun.jndi.ldap.LdapCtxFactory";
                              String MY_HOST = "ldap://KhooGP-Comp1:1389";
                              String MGR_DN = "cn=Directory Manager";
                              String MGR_PW = "password";
                              String MY_SEARCHBASE = "dc=QuizPortal";
                              String MY_FILTER = "uid=yiwei";
                              String MY_ATTRS[] = {"cn", "uid", "sn", "userpassword"};
                  
                              //Identify service provider to use
                              Hashtable env = new Hashtable();
                              env.put(Context.INITIAL_CONTEXT_FACTORY, INITCTX);
                              env.put(Context.PROVIDER_URL, MY_HOST);
                  
                              env.put(Context.SECURITY_AUTHENTICATION, "simple");
                              env.put(Context.SECURITY_PRINCIPAL, MGR_DN);
                              env.put(Context.SECURITY_CREDENTIALS, MGR_PW);
                  
                              try
                              {
                                  // Create the initial directory context
                                  InitialDirContext initialContext = new InitialDirContext(env);
                                  DirContext ctx = (DirContext)initialContext;
                  
                                  System.out.println("Context Sucessfully Initialized");
                  
                                  SearchControls constraints = new SearchControls();
                                  constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
                  
                                  NamingEnumeration results = ctx.search(MY_SEARCHBASE, MY_FILTER, constraints);
                  
                                  while(results != null && results.hasMore())
                                  {
                                      SearchResult sr = (SearchResult) results.next();
                                      String dn = sr.getName() + "," + MY_SEARCHBASE;
                                      System.out.println("Distinguished Name is " + dn);
                  
                                      Attributes ar = ctx.getAttributes(dn, MY_ATTRS);
                  
                                      if(ar == null)
                                      {
                                          System.out.println("Entry " + dn);
                                          System.out.println(" has none of the specified attributes
                  ");
                                      }
                                      else
                                      {
                                          for(int i=0; i<MY_ATTRS.length; i++)
                                          {
                                              Attribute attr = ar.get(MY_ATTRS[i]);
                                              System.out.println(MY_ATTRS[i] + ":");
                  
                                              for(Enumeration vals=attr.getAll(); vals.hasMoreElements();)
                                              {
                                                  System.out.println("	" + vals.nextElement());
                                              }
                                          }
                                      }
                                  }
                              }
                              catch(Exception e)
                              {
                                  System.err.println(e);
                              }
                      }
                  
                  Below is the result:
                  
                      Distinguished Name is uid=yiwei,ou=Administrator,o=SID,dc=QuizPortal
                      cn:
                              yiwei huang
                      uid:
                              yiwei
                      sn:
                              huang
                      userpassword:
                              [B@1cd8669
                  

                  有什么建议吗??非常感谢提前

                  Any advice?? Many thanks in advance

                  凯文

                  推荐答案

                  您所看到的 ([B@1cd8669) 是 Java 表示这是一个字节数组"的方式.

                  What you're seeing ([B@1cd8669) is Java's way of saying "this is a byte array".

                  存储的密码"很可能是真实密码的哈希或加密版本.根据定义,加密哈希是不可逆的,因此如果 LDAP 存储哈希,您将无法看到用户的密码.

                  The stored "password" is most likely either a hash of the real password or an encrypted version. Cryptographic hashes are, by definition, non-reversible so you will not be able to see what the user's password is if LDAP stores the hash.

                  如果它是加密的,那么如果你知道算法和密钥,那么解密就相当简单.BouncyCastle 是一个很棒的 Java 加密库,可用于解密密码.

                  If it's encrypted then if you know the algorithm and the key it's fairly simple to decrypt. BouncyCastle is a great Java crypto library you can use to decrypt the password.

                  基本上,您需要确切地知道您正在查看的内容,这取决于 LDAP 设置.

                  Basically, you need to know exactly what you're looking at, and that will depend on the LDAP setup.

                  这篇关于如何通过 JNDI 检索 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 中的默认语言环境设置以使其保持一致?)
                • <tfoot id='wPQ55'></tfoot>

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

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

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