彬彬931120 2017-08-17 06:06 采纳率: 0%
浏览 2294
已结题

ldap服务器怎么实现SASL安全认证方式

最近在做ldap服务器的认证,要求支持三种(none,simple,strong)连接方式,
但是现在只支持两种none和simple两种方式,对于strong方式的DIGEST-MD5,NTLM, CRAM-MD等方式都不支持。ldapConnect链接代码如下

     public LdapContext getLdapConnection(String userName, String passwd) {
        LdapContext ldapContext = null;
        // 用户名称,cn,ou,dc 分别:用户,组,域
        env.put(Context.SECURITY_PRINCIPAL, userName);
        // 用户密码 cn 的密码
        env.put(Context.SECURITY_CREDENTIALS, passwd);
        // url 格式:协议://ip:端口/组,域 ,直接连接到域或者组上面
        env.put(Context.PROVIDER_URL, "ldap://192.168.7.245:389/dc=thundersoft,dc=com");
        // LDAP 工厂
        env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        // 验证的类型 "none", "simple", "strong"
        env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5");
        try {
            ldapContext = new InitialLdapContext(env, null);
            System.out.println("---connection is ready----");
        } catch (NamingException e) {
            // e.printStackTrace();
            System.out.println("--- get connection failure ----");
        }
        return ldapContext;
    }

Context.SECURITY_AUTHENTICATION 这个属性的值为none和simple时都能链接成功
但当其值为 DIGEST-MD时报下面这个错

javax.naming.AuthenticationException: [LDAP: error code 49 - SASL(-13): user not found: no secret in database]
当然这个sasl用户在服务起中是没有添加的,但是现在问题在于 :
1)我不确定我安装的ldap服务器是否支持sasl认证
2)我不知道如何想ldap服务器中添加SASL用户;网上的资料一般都是 运行 saslpasswd2 -c test(用户名),之后输入密码和确认密码来完成的,但是当我运行这个命令的时候也会报错 saslpasswd2: generic failure ,以root来运行时又会出现
BDB3037 /etc/sasldb2: file size not a multiple of the pagesize
saslpasswd2: generic failure 这个错误。
有没有对ldap比较了解的希望能帮忙解答一下

  • 写回答

1条回答 默认 最新

  • 彬彬931120 2017-08-17 07:03
    关注

    这是完整的异常
    Exception in thread "main" javax.naming.AuthenticationException: [LDAP: error code 49 - SASL(-13): user not found: no secret in database]
    at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3154)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3100)
    at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:2886)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2800)
    at com.sun.jndi.ldap.LdapCtx.(LdapCtx.java:319)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:192)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:210)
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:153)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:83)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:684)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:313)
    at javax.naming.InitialContext.init(InitialContext.java:244)
    at javax.naming.ldap.InitialLdapContext.(InitialLdapContext.java:154)
    at test.TestLDAP.getLdapConnection(TestLDAP.java:46)
    at test.TestLDAP.main(TestLDAP.java:69)

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器