Skip to content

Commit af8a89b

Browse files
authored
[#530] Fixed error when creating a backend for BASE_DN with OU in Docker (#531)
1 parent c4806f2 commit af8a89b

2 files changed

Lines changed: 27 additions & 13 deletions

File tree

opendj-doc-generated-ref/src/main/asciidoc/admin-guide/chap-import-export.adoc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
information: "Portions copyright [year] [name of copyright owner]".
1313

1414
Copyright 2017 ForgeRock AS.
15-
Portions Copyright 2024 3A Systems LLC.
15+
Portions Copyright 2025 3A Systems LLC.
1616
////
1717
1818
:figure-caption!:
@@ -348,6 +348,26 @@ enabled : true
348348
index-entry-limit : 4000
349349
writability-mode : enabled
350350
----
351+
352+
If you want to add a base entry, create a template file with the base DN, for example `base.template`:
353+
[source]
354+
----
355+
branch: dc=example,dc=com
356+
----
357+
358+
And then use the `import-ldif` tool to import a template file as shown in the following example:
359+
360+
[source, console]
361+
----
362+
$ /opt/opendj/bin/import-ldif \
363+
--templateFile base.template \
364+
--backendID myData \
365+
--bindDN "cn=Directory Manager" \
366+
--bindPassword password
367+
----
368+
369+
For details see xref:../reference/admin-tools-ref.adoc#import-ldif-1[import-ldif(1)] in the __Reference__.
370+
351371
Alternatively, you can create a new backend in OpenDJ control panel (Directory Data > New Base DN > Backend > New Backend: __backend-name__).
352372
When you create a new backend using the `dsconfig` command, OpenDJ directory server creates the following indexes automatically:
353373
[none]

opendj-packages/opendj-docker/bootstrap/setup.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,12 @@ echo "creating backend: $BACKEND_TYPE db-directory: ${BACKEND_DB_DIRECTORY}"
4141
--set enabled:true --no-prompt --trustAll
4242

4343
if [ "$ADD_BASE_ENTRY" = "--addBaseEntry" ]; then
44-
45-
DC=$(echo "$BASE_DN" | awk -F',|=' '{print $2}')
46-
47-
/opt/opendj/bin/ldapmodify --hostname localhost \
48-
--port 1636 --bindDN "$ROOT_USER_DN" --bindPassword "$ROOT_PASSWORD" \
49-
--useSsl --trustAll <<EOF
50-
dn: $BASE_DN
51-
dc: $DC
52-
objectClass: domain
53-
objectClass: top
54-
EOF
55-
44+
echo "creating base entry..."
45+
BASE_TEMPLATE=$(mktemp)
46+
echo "branch: $BASE_DN" > $BASE_TEMPLATE
47+
/opt/opendj/bin/import-ldif --templateFile $BASE_TEMPLATE \
48+
--backendID=userRoot --bindDN "$ROOT_USER_DN" --bindPassword "$ROOT_PASSWORD"
49+
rm $BASE_TEMPLATE
5650
fi
5751

5852

0 commit comments

Comments
 (0)