我正在运行一个Spring-boot应用程序,它使用spring-security-ldap通过内部LDAP对用户进行身份验证。
默认情况下,它以匿名方式与LDAP绑定。
Property 'userDn' not set - anonymous context will be used for read-write operations
但我希望第一个绑定是与当前用户名。
我应该在哪里指定userDn属性?
谢谢你的建议
发布于 2020-07-16 16:32:32
关于Spring-boot,我不是最有见识的人,在LDAP方面更是如此。也就是说,应该在application.properties文件中提到LDAP配置属性,并将其命名为spring.ldap.*。在documentation here中提到了它们。
初始化身份验证提供程序时,您可以使用以下命令传递重要属性,如基本DN (要搜索的根目录)和筛选器:
.userSearchBase("ou=<your users container>").userSearchFilter("(uid={0})")最有可能的是,您的搜索筛选器将是uid={0}或cn={0}。
发布于 2021-07-28 16:58:48
当使用spring ldap时,你可能是从web上的许多教程开始的,但大多数都使用嵌入式ldap服务器;嵌入式服务器使用ldif文件,不需要管理员证书。
当连接到外部ldap服务器时,您需要指定通过managerDn方法设置的userDn。下面是一段代码
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication().contextSource().managerDn("uid=admin,ou=system")
.managerPassword("secret")
.......
}显然,您还需要提供所有其他信息,如url、端口等(以及像mvreijn told这样的userSearchBase )。
https://stackoverflow.com/questions/62897293
复制相似问题