gpt4 book ai didi

spring - 如何转换grails 2 LDAP Active Directory值以使用Spring Boot

转载 作者:行者123 更新时间:2023-12-02 15:44:23 25 4
gpt4 key购买 nike

我在使用Spring Boot连接到LDAP Active Directory时遇到问题。我一直在使用在Grails 2应用程序中找到的值,但一定缺少一些东西。

Grails 2值示例

grails.plugin.springsecurity.ldap.authorities.retrieveDatabaseRoles = true
grails.plugin.springsecurity.ldap.context.managerDn = 'manager@domain.local'
grails.plugin.springsecurity.ldap.context.managerPassword = 'password'
grails.plugin.springsecurity.ldap.context.server = 'ldap://domain.local:389'
grails.plugin.springsecurity.ldap.authorities.ignorePartialResultException = true
grails.plugin.springsecurity.ldap.search.base = 'ou=users,dc=domain,dc=local'
grails.plugin.springsecurity.ldap.search.filter = "sAMAccountName={0}"
grails.plugin.springsecurity.ldap.search.searchSubtree = true
grails.plugin.springsecurity.ldap.auth.hideUserNotFoundExceptions = false
grails.plugin.springsecurity.ldap.search.attributesToReturn = ['mail', 'displayName']
grails.plugin.springsecurity.providerNames = ['customAuthenticationProvider','ldapAuthProvider']

这是我在Spring Boot中尝试的众多变体之一。我很肯定它没有正确搜索管理员/密码。
@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().fullyAuthenticated()
.and()
.formLogin();
}

@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.contextSource().url("ldap://domain.local:389")
.managerDn("uid=manager@domain.local,ou=users")
.managerPassword("password")
.and()
.userSearchBase("ou=users,dc=domain,dc=local")
.userDnPatterns("sAMAccountName={0}");

}
}

build.gradle ldap依赖项
compile("org.springframework.ldap:spring-ldap-core")
compile("org.springframework.security:spring-security-ldap")
compile("com.unboundid:unboundid-ldapsdk")

最佳答案

通过如下设置使其正常工作:

        auth.ldapAuthentication()
.contextSource().url("ldap://domain.local:389/ou=users,dc=domain,dc=local")
.managerDn("manager@domain.local").managerPassword("password")
.and()
.userSearchFilter("sAMAccountName={0}");

关于spring - 如何转换grails 2 LDAP Active Directory值以使用Spring Boot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51158296/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com