# 30.9.3 嵌入式内存中LDAP服务器

为了方便测试，Spring Boot支持[UnboundID](https://www.ldap.com/unboundid-ldap-sdk-for-java) 的嵌入式内存中LDAP服务器的自动配置。在`com.unboundid:unboundid-ldapsdk`里添加依赖，声明`base-dn`属性，来配置服务器：

```
spring.ldap.embedded.base-dn=dc=spring,dc=io
```

**注** 定义多个base-dn的值是可行的。但是，识别名称通常包含逗号。它们必须使用正确的符号定义。

在yaml文件里，你可以使用yaml列表符号：

```
spring.ldap.embedded.base-dn:
  - dc=spring,dc=io
  - dc=pivotal,dc=io
```

在properties文件里，你必须把索引作为属性名的一部分：

```
spring.ldap.embedded.base-dn[0]=dc=spring,dc=io
spring.ldap.embedded.base-dn[1]=dc=pivotal,dc=io
```

默认地，服务器会在一个随机的端口中开始运行。它们会触发常规的LDAP支持（不需要指定`spring.ldap.urls`属性）。 如果在你的类路径下存在`schema.ldif`文件，它会被用于初始化服务器。如果你想要从不同的资源加载初始化脚本，你可以使用`pring.ldap.embedded.ldif`属性。

默认地，一个标准的模式会被用于验证`LDIF`文件，你可以设置`spring.ldap.embedded.validation.enabled`属性完全地关闭验证。如果你有自定义的属性，你可以使用`spring.ldap.embedded.validation.schema`来定义你的自定义属性类型或对象类。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/30.-working-with-nosql-technologies/30.9-ldap/30.9.3-embedded-in-memory-ldap-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
