How-to: Samba - Delete an Object from the Samba DB

How to:

Short guideline how you could delete an Object from the Samba DB.

Step 1: Get the correct DN for the Object.

You will need the right DN of the object, you could use the S4-Connector for that.

univention-s4search ou=Test-OU

# record 1
dn: OU=Test-OU,DC=ucs5schoolhejne,DC=intranet
objectClass: top
objectClass: organizationalUnit
ou: Test-OU
description: deaktivierte Rechnerobjekte
instanceType: 4
whenCreated: 20240513143422.0Z
whenChanged: 20240513143422.0Z
uSNCreated: 8102
uSNChanged: 8102
name: Test-OU
objectGUID: daed9efa-3e9b-4138-bf07-78cab9c0318d
objectCategory: CN=Organizational-Unit,CN=Schema,CN=Configuration,DC=ucs5schoo
distinguishedName: OU=Test-OU,DC=ucs5schoolhejne,DC=intranet

# Referral
ref: ldaps://ucs5schoolhejne.intranet/CN=Configuration,DC=ucs5schoolhejne,DC=intranet

# Referral
ref: ldaps://ucs5schoolhejne.intranet/DC=DomainDnsZones,DC=ucs5schoolhejne,DC=intranet

# Referral
ref: ldaps://ucs5schoolhejne.intranet/DC=ForestDnsZones,DC=ucs5schoolhejne,DC=intranet

# returned 4 records
# 1 entries
# 3 referrals

Step 2: Delete the Object from the Samba DB.

With the following command you could the Object with the DN above.

ldbdel -H /var/lib/samba/private/sam.ldb 'OU=Test-OU,DC=ucs5schoolhejne,DC=intranet'
Deleted 1 record