Java 使用Jetty的LDAP身份验证

Java 使用Jetty的LDAP身份验证,java,authentication,ldap,jetty,jaas,Java,Authentication,Ldap,Jetty,Jaas,我正在尝试在Jetty上使用Jaas设置基于LDAP的身份验证 我首先配置了Jetty->Jass尝试使用属性文件登录模块,然后在配置完成后,我将更改为基于Ldap的登录模块。。。但我有一个奇怪的问题: 我有这个配置 jettyLogin { org.eclipse.jetty.plus.jaas.spi.LdapLoginModule required debug="true" contextFactory="com.sun.jndi.ldap.LdapCtxFactor

我正在尝试在Jetty上使用Jaas设置基于LDAP的身份验证

我首先配置了
Jetty->Jass
尝试使用属性文件登录模块,然后在配置完成后,我将更改为基于Ldap的登录模块。。。但我有一个奇怪的问题:

我有这个配置

jettyLogin {
   org.eclipse.jetty.plus.jaas.spi.LdapLoginModule required
    debug="true"
    contextFactory="com.sun.jndi.ldap.LdapCtxFactory"
    hostname="localhost"
    port="1389"
    bindDn="uid=admin,ou=People,o=acme,dc=example,dc=com"
    bindPassword="admin"
    authenticationMethod="simple"
    forceBindingLogin="false"
    userBaseDn="ou=People,o=acme,dc=example,dc=com"
    userRdnAttribute="uid"
    userIdAttribute="uid"
    userPasswordAttribute="userPassword"
    userObjectClass="inetOrgPerson"
    roleBaseDn="ou=Roles,o=acme,dc=example,dc=com"
    roleNameAttribute="cn"
    roleMemberAttribute="member"
    roleObjectClass="groupOfNames";
   };
对于这样的LDAP条目

dn: uid=jduke,ou=People,o=acme,dc=example,dc=com
objectclass: top
objectclass: inetOrgPerson
objectclass: person
uid: jduke
cn: Java
sn: Duke
userPassword: theduke
mail: jduke@acme.example.com
我看到的是
LdapLoginModule
被调用并搜索用户;已找到用户,但在检索属性时,userPassword属性丢失(!!)。。。然后它保持为null,身份验证失败


我无法理解为什么未检索到
userPassword
属性。

登录模块不应尝试检索userPassword属性。LDAP是一种身份验证协议,它有自己的方法,称为绑定

如果配置正确,Jetty的JAAS模块将尝试使用提供的凭据执行绑定。如果你改变

forceBindingLogin="false"


在您的配置中,它应该适合您

登录模块不应尝试检索userPassword属性。LDAP是一种身份验证协议,它有自己的方法,称为绑定

如果配置正确,Jetty的JAAS模块将尝试使用提供的凭据执行绑定。如果你改变

forceBindingLogin="false"


在您的配置中,它应该适合您

很少有LDAP实现会返回userPassword值,它们不应该返回。您不应该期望收到userPAssword的值。用户应提供密码,应用程序应绑定为user.mmm。。。也许我错了,但在我看来,验证用户身份的操作不是由LDAP服务器完成的。。。所以服务器应该以任何方式提供密码,以便与用户提供的密码进行比较。。。这样,身份验证操作由登录模块执行。Ldap登录模块的代码看起来非常清晰。它希望找到LDAP检索到的userPassword属性。我不熟悉登录模块,但很少有LDAP实现会返回userPassword值,而且它们不应该返回。很少有LDAP实现会返回userPassword值,而且它们不应该返回。您不应该期望收到userPAssword的值。用户应提供密码,应用程序应绑定为user.mmm。。。也许我错了,但在我看来,验证用户身份的操作不是由LDAP服务器完成的。。。所以服务器应该以任何方式提供密码,以便与用户提供的密码进行比较。。。这样,身份验证操作由登录模块执行。Ldap登录模块的代码看起来非常清晰。它期望找到LDAP检索到的userPassword属性。我不熟悉登录模块,但是很少有LDAP实现会返回userPassword值,而且它们不应该返回。