For local development I docker compose file like that:
version: '3.4'
networks:
dsm:
services:
samba:
image: instantlinux/samba-dc:latest
container_name: samba-dc
cap_add:
- CAP_SYS_ADMIN
hostname: inno.tech
environment:
DOMAIN_ACTION: provision
REALM: my.company
volumes:
- etc:/etc/samba
- lib:/var/lib/samba
ports:
- "389:389"
secrets:
- samba-admin-password
volumes:
etc:
lib:
secrets:
samba-admin-password:
file: secrets.yaml
Also I up the same server in tests using testContainers
val adminPasswordFile = getSecretPassword(ResourceUtils.getFile("classpath:$SECRET_FILE_NAME"))
val domainName = getDomainName(ResourceUtils.getFile("classpath:$APPLICATION_CONFIG_FILENAME"))
val secretPathInContainer = "/run/secrets/samba-admin-password"
// Create and start the container
return GenericContainer(SAMBA_IMAGE)
.withEnv("DOMAIN_ACTION", "provision")
.withEnv("REALM", domainName)
.withEnv(
"ADMIN_PASSWORD_SECRET",
adminPasswordFile,
)
.withPrivilegedMode(true)
.withExposedPorts(389)
.withCopyToContainer(
MountableFile.forClasspathResource(SECRET_FILE_NAME, Transferable.DEFAULT_FILE_MODE),
secretPathInContainer,
)
In both cases I would like to have an ability to load LDAP data (for example on startup but it is not mandatory) for both cases but mostly for tests.
I already have ldif file so I started to investigate it (but if there are other ways to do it – I am ready to use them)
Source my ideas is https://wiki.samba.org/index.php/Back_up_and_Restoring_a_Samba_AD_DC#Offline.2Flocal_DC_backup
I’ve found the command:
sudo samba-tool domain backup restore --backup-file=<tar-file> --newservername=<DC-name> --targetdir=<new-samba-dir>
But tar file is used here.
Based on https://lists.samba.org/archive/samba/2018-November/219439.html
and
It also works only with tar files.
To be honest I tried to make backup using the command but no luck(it just hangs):
If I add sudo in the begining – I see error that sudo: not found
and I have no idea what to do next.
Also I’ve met this link:
https://wiki.samba.org/index.php/Administer_Unix_Attributes_in_AD_using_samba-tool_and_ldb-tools
Wheere I’ve found command
ldbmodify -H /usr/local/samba/private/sam.ldb /tmp/group.ldif -U Administrator
but when I tried to execute it I’ve got an error:
Unable to open tdb ‘/usr/local/samba/private/sam.ldb’: No such file or directory
Failed to connect to '/usr/local/samba/private/sam.ldb' with backend 'tdb': Unable to open tdb '/usr/local/samba/private/sam.ldb': No such file or directory
Failed to connect to /usr/local/samba/private/sam.ldb - Unable to open tdb '/usr/local/samba/private/sam.ldb': No such file or directory
is there way to upload file somehow ?