我正在努力让LDAP身份验证与Active Directory一起工作。
我们刚刚安装了一个SharePoint Server 2010,我们认为还可以根据Active Directory对用户进行身份验证,因为它已经用于SharePoint。我们的环境是Windows Server 2008 R2标准。
根据这个答案https://serverfault.com/a/130556我的提供商URL应该是ldap://192.168.0.81:389/CN=Users,DC=rdl,DC=com,DC=tw
(请注意,我没有使用vm-sps.rdl.com.tw的主机名,而是选择使用IP地址,因为我没有时间为所述服务器配置DNS条目)
然而,我就是无法进行身份验证工作。我已经按照LdapLoginModule API尝试了所有三种类型的JAAS配置
以下是我遇到的错误:
1.搜索第一模式:
注意:我没有指定authzIdentity,因为我在广告上没有这个设置
JAAS配置:
AESLogin_AD1 {
com.sun.security.auth.module.LdapLoginModule REQUIRED
userProvider="ldap://192.168.0.81:389/CN=Users,DC=rdl,DC=com,DC=tw"
userFilter="(&(uid={USERNAME})(objectClass=User))"
useSSL=false
debug=true;
};
结果:
[LdapLoginModule] search-first mode; SSL disabled
[LdapLoginModule] user provider: ldap://192.168.0.81:389/CN=Users,DC=rdl,DC=com,DC=tw
[LdapLoginModule] searching for entry belonging to user: ahsieh@rdl.com.tw
[LdapLoginModule] authentication failed
[LdapLoginModule] aborted authentication
javax.security.auth.login.FailedLoginException: Cannot find user's LDAP entry
2.认证优先模式
JAAS配置:
AESLogin_AD2 {
com.sun.security.auth.module.LdapLoginModule REQUIRED
userProvider="ldap:///CN=Users,DC=rdl,DC=com,DC=tw"
authIdentity="{USERNAME}"
userFilter="(&(|(samAccountName={USERNAME})(userPrincipalName={USERNAME})(cn={USERNAME}))(objectClass=user))"
useSSL=false
debug=true;
};
结果:
[LdapLoginModule] authentication-first mode; SSL disabled
[LdapLoginModule] user provider: ldap:///CN=Users,DC=rdl,DC=com,DC=tw
[LdapLoginModule] attempting to authenticate user: ahsieh@rdl.com.tw
[LdapLoginModule] authentication failed
[LdapLoginModule] aborted authentication
javax.security.auth.login.FailedLoginException: Cannot bind to LDAP server
3.仅认证模式
注意:我没有指定authzIdentity,因为我在广告上没有这个设置
JAAS配置:
AESLogin_AD3 {
com.sun.security.auth.module.LdapLoginModule REQUIRED
userProvider="ldap://192.168.0.81:389"
authIdentity="CN={USERNAME},CN=Users,DC=rdl,DC=com,DC=tw"
useSSL=false
debug=true;
};
结果:
[LdapLoginModule] authentication-only mode; SSL disabled
[LdapLoginModule] user provider: ldap://192.168.0.81:389
[LdapLoginModule] attempting to authenticate user: ahsieh@rdl.com.tw
[LdapLoginModule] authentication failed
[LdapLoginModule] aborted authentication
javax.security.auth.login.FailedLoginException: Cannot bind to LDAP server
我还尝试了另一个配置,基于我在互联网上遇到的一些例子:
4.来自其他示例的配置
JAAS配置:
AESLogin_AD4 {
com.sun.security.auth.module.LdapLoginModule REQUIRED
userProvider="ldap://192.168.0.81:389/CN=Users,DC=rdl,DC=com,DC=tw"
authIdentity="{USERNAME}"
useSSL=false
debug=true;
};
结果:
[LdapLoginModule] authentication-only mode; SSL disabled
[LdapLoginModule] user provider: ldap://192.168.0.81:389/CN=Users,DC=rdl,DC=com,DC=tw
[LdapLoginModule] attempting to authenticate user: ahsieh@rdl.com.tw
[LdapLoginModule] cannot create LdapPrincipal: bad DN
[LdapLoginModule] authentication failed
[LdapLoginModule] aborted authentication
javax.security.auth.login.FailedLoginException: Cannot create LdapPrincipal
注意:我的第四次尝试似乎取得了一些进展,因为至少LDAP绑定似乎可以工作,但现在的问题似乎是无法创建LdapPrincipal:bad DN
我已经深入了解了LdapLoginModule
的源代码,通过匹配调试消息,似乎这是由(第837行开始)引起的:
try {
ldapPrincipal = new LdapPrincipal(dn);
} catch (InvalidNameException e) {
if (debug) {
System.out.println("\t\t[LdapLoginModule] " +
"cannot create LdapPrincipal: bad DN");
}
throw (LoginException)
new FailedLoginException("Cannot create LdapPrincipal")
.initCause(e);
}
基于LdapPrincipal API,如果检测到语法冲突,就会抛出InvalidNameException
,但我不知道语法冲突在哪里。
我也不知道如何调试这个。
任何帮助将不胜感激!谢谢!
我在网上浏览了更多的文章,最终从Bonitasoft的Q中找到了解决方案
JAAS配置:
AESLogin_ADx {
com.sun.security.auth.module.LdapLoginModule REQUIRED
userProvider="ldap://192.168.0.81:389/CN=Users,DC=rdl,DC=com,DC=tw"
authIdentity="{USERNAME}@rdl.com.tw"
userFilter="(&(|(samAccountName={USERNAME})(userPrincipalName={USERNAME})(cn={USERNAME}))(objectClass=user))"
useSSL=false
debug=true;
};
结果:
[LdapLoginModule] authentication-first mode; SSL disabled
[LdapLoginModule] user provider: ldap://192.168.0.81:389/CN=Users,DC=rdl,DC=com,DC=tw
[LdapLoginModule] attempting to authenticate user: ahsieh
[LdapLoginModule] searching for entry belonging to user: ahsieh
[LdapLoginModule] found entry: CN=Arthur Hsieh,CN=Users,DC=rdl,DC=com,DC=tw
[LdapLoginModule] authentication succeeded
[LdapLoginModule] added LdapPrincipal "CN=Arthur Hsieh,CN=Users,DC=rdl,DC=com,DC=tw" to Subject
[LdapLoginModule] added UserPrincipal "ahsieh" to Subject
我正在尝试使用urllib3连接到网页。代码如下所示。 如果我们假设url是需要使用用户名和密码进行身份验证的某个网页,那么我是否使用正确的代码进行身份验证? 我使用urllib2做这件事很舒服,但使用urllib3做不到同样的事情。 非常感谢
jwt不应该仅仅用于认证用户吗?我读到过可以在里面存储非敏感的东西,比如用户ID。将权限级别之类的东西存储在令牌中可以吗?这样我可以避免数据库调用。
问题内容: 我可以通过接收到请求的xml 但不是 没有JavaScript错误,没有跨域策略问题。可能是语法错误,但是我找不到合适的教程。有什么建议吗? 问题答案: 我认为您需要纯格式:
我想为登录创建自定义endpoint。 当密码和用户名正确时,它可以正常工作,但对于不正确的数据返回200和登录表单而不是401。 public-class-SecurityConfiguration扩展了WebSecurityConfigurerAdapter{private-final-UserDetailsService-UserDetailsService; }
问题内容: 我需要使用PostForm方法将代理与auth一起使用。如果我使用类似(简体)的内容: 我可以轻松做到,并且效果很好。但是现在,我正在编辑第三方程序包,并尝试将代理添加到现有代码中: 在我看来,它是行不通的,而且失败了。在此示例中,没有身份验证的代理可以正常工作。有人知道吗,在这种情况下我可以在auth中使用代理吗? 问题答案: 您正在尝试向响应中添加标头,这不是您发送到服务器的内容,
问题内容: 我想使用mongoengine db在Django项目中处理身份验证。 我尝试了一些有关此问题的示例,这些问题已在旧问题中得到解答,但并未运行。我正在使用Django 1.6和mongoengine。一切都已安装,运行,并且我可以创建文档并将其保存到Mongoengine DB。 我正在追踪http://mongoengine- odm.readthedocs.org/en/lates