<legend id='J6pVi'><style id='J6pVi'><dir id='J6pVi'><q id='J6pVi'></q></dir></style></legend>
        <bdo id='J6pVi'></bdo><ul id='J6pVi'></ul>

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

    3. java - 如何使用给定的LdapContext检查ldap中的用户密码?

      时间:2023-10-14

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

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

              <bdo id='ecVia'></bdo><ul id='ecVia'></ul>
                本文介绍了java - 如何使用给定的LdapContext检查ldap中的用户密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我确实有一个网络应用程序,用户必须在其中登录.密码存储在 LDAP 服务器中.有关 LDAP 服务器的所有信息都作为外部 jndi 资源存储在应用程序服务器 (glassfish) 中.所以我的应用程序对 LDAP 服务器一无所知,只得到一个像这样的 LdapContext:

                I do have a web-application, where users must log in. The password is stored in a LDAP server. All information about the LDAP server are stored in the application server (glassfish) as external jndi resource. So my application does no know anything about the LDAP server and only gets a LdapContext like this:

                @Resource(name = "ldap/users")
                private LdapContext ctx;
                

                在这种情况下,很容易更改或读取为用户存储的信息,但我如何检查他们的密码?通常我会做一个新的连接来检查用户密码.像这样:

                With this context it is easy to change or read the information stored for the users, but how do i check their passwords? Normally i would just do a new connection to check a users password. Like this:

                Hashtable env = new Hashtable();
                env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
                env.put(Context.PROVIDER_URL, "ldap://localhost:389/o=JNDITutorial");
                
                env.put(Context.SECURITY_AUTHENTICATION, "simple");
                env.put(Context.SECURITY_PRINCIPAL, "cn=S. User, ou=NewHires, o=JNDITutorial");
                env.put(Context.SECURITY_CREDENTIALS, "mysecret");
                
                DirContext ctx = new InitialDirContext(env);
                

                但是由于我不知道 this 参数,所以我不能这样做.那么如何使用我的 LdapContext 检查用户的密码是否正确?密码是加密存储的(ssha),所以我不能只比较属性.

                But since i don't know the this parameters i can't do this. So how do i check if the password of a user is correct with my LdapContext? The passwords are stored encrypted (ssha) so i can not just compare the attributes.

                谢谢拉斐尔

                推荐答案

                您应该能够从 ldap 上下文中获取环境,克隆它,然后为您要检查的用户放置主体和凭据:

                You should be able to get the environment from the ldap context, clone it, and then put the principal and credentials for the user you want to check:

                @Resource(name = "ldap/users")
                private LdapContext ldapContext;
                
                Hashtable environment = ldapContext.getEnvironment().clone();
                environment.put(Context.SECURITY_PRINCIPAL, userDN);
                environment.put(Context.SECURITY_CREDENTIALS, userPassword);
                
                DirContext dirContext = new InitialDirContext(environment);
                

                这篇关于java - 如何使用给定的LdapContext检查ldap中的用户密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:Spring 安全切换到 Ldap 身份验证和数据库权限 下一篇:带有错误 Active Directory Ldap 凭据的 Session/Redis 序列化错误的 Spring B

                相关文章

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

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

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

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