【问题标题】:Dynamically configure LDAP server Properties using text file使用文本文件动态配置 LDAP 服务器属性
【发布时间】:2022-01-21 14:51:39
【问题描述】:

我目前正在使用带有 XML 配置的 Spring Security 使用 LDAP。我需要关于如何将 URL、端口、manager-dn 和密码等属性放入外部文件的建议。

<ldap-server id="ldapServer"
        url="ldap://xxxxx:3268/dc=xxxxx,dc=com" port="3268"
        manager-dn="xxxxx@xxxxx.com" manager-password="xxxxxx" />

我的意思是,我们需要将其放在外部,因为我们的其他团队(实施团队)需要更改这些属性值才能上线,而无需更改 war/binary 文件中的任何内容。谢谢

【问题讨论】:

标签: spring spring-security-ldap


【解决方案1】:

完成,感谢this 发帖

步骤:

  1. 创建属性文件并将其放入服务器

####### LDAP ##############
ldap.urls= ldap://xxxx:3268/dc=xxxxx,dc=com
ldap.manager-dn= xxxx@xxxxx.com
ldap.manager-password= xxxx
  1. 创建properyplaceholder bean

<beans:bean
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <beans:property name="location">
            <beans:value>file:///opt/xxxx/xxxxx/application.properties</beans:value>
        </beans:property>
    </beans:bean>
  1. 从 XML bean 访问属性

<ldap-server id="ldapServer" url="${ldap.urls}" port="3268"
        manager-dn="${ldap.manager-dn}"
        manager-password="${ldap.manager-password}" />

【讨论】:

    猜你喜欢
    • 2016-08-29
    • 2015-01-03
    • 2015-02-18
    • 2020-02-14
    • 1970-01-01
    • 2015-06-18
    • 2020-11-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多