I've installed Samba 4.9.5-Debian with Active Directory role on Debian 10. The installation is configured with SAMBA_INTERNAL DNS backend. When I try to connect with LDAPS with domain connected Windows 10 laptop with ldp.exe I get error below. Decrypted 389 works fine.
ld = ldap_sslinit("smb-dc01", 636, 1);
Error 0 = ldap_set_option(hLdap, LDAP_OPT_PROTOCOL_VERSION, 3);
Error 81 = ldap_connect(hLdap, NULL);
Server error: <empty>
Error <0x51>: Fail to connect to smb-dc01.
Settings in ldp.exe:
Connect ->
Server: smb-dc01
Port: 636
SSL: checked
When trying to connect LDAP with domain joined machine, the DC log /var/log/samba/log.samba shows:
[2020/04/02 17:41:11.671421, 3] ../lib/ldb-samba/ldb_wrap.c:332(ldb_wrap_connect)
ldb_wrap open of secrets.ldb
[2020/04/02 17:41:11.695211, 3] ../source4/smbd/service_stream.c:67(stream_terminate_connection) stream_terminate_connection: Terminating connection - 'ldapsrv_accept_tls_loop: tstream_tls_accept_recv() - 32:Broken pipe'
If I add the below line to Windows 10 machine's hosts file, then the machine will connect to LDAPS.
192.168.23.54 smb-dc01
I'm not sure what's wrong with the configuration. Non-domain-joined machines work with same settings. It seems quite peculiar that not-domain-joined machines work better than domain-joined.
Configuration files on the Samba DC:
/etc/samba/smb.conf
# Global parameters
[global]
dns forwarder = 192.168.23.5
netbios name = SMB-DC01
realm = DM.EXAMPLE.COM
server role = active directory domain controller
workgroup = DM
idmap_ldb:use rfc2307 = yes
tls enabled = yes
tls keyfile = tls/smb-dc01.key
tls certfile = tls/smb-dc01-server.cer
tls cafile = tls/root-ca.cer
# Debugging / logging
# https://serverfault.com/questions/389166/how-to-debug-samba-authorization-authentication-procedure
log level = 3
[netlogon]
path = /var/lib/samba/sysvol/dm.example.com/scripts
read only = No
[sysvol]
path = /var/lib/samba/sysvol
read only = No
/etc/resolv.conf
domain dm.example.com
search dm.example.com
nameserver 192.168.23.54
/etc/krb5.conf
[libdefaults]
default_realm = DM.EXAMPLE.COM
dns_lookup_realm = false
dns_lookup_kdc = true
/etc/hosts
127.0.0.1 localhost
192.168.23.54 smb-dc01.dm.example.com smb-dc01
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Test with non-domain-joined Windows 10 machines
I tested with two different Windows 10 machines, one is joined to another domain and one is without any domain. Connecting to LDAPS works good when DNS is set to point the Samba DC.
Log /var/log/samba/log.samba of successful connect / disconnect:
# Connect
[2020/04/02 17:38:17.646796, 3] ../lib/ldb-samba/ldb_wrap.c:332(ldb_wrap_connect)
ldb_wrap open of secrets.ldb
# Disconnect
[2020/04/02 17:39:42.623855, 2] ../source4/dsdb/kcc/kcc_periodic.c:785(kccsrv_samba_kcc)
Calling samba_kcc script
[2020/04/02 17:39:42.825060, 0] ../lib/util/util_runcmd.c:327(samba_runcmd_io_handler)
/usr/sbin/samba_kcc: ldb_wrap open of secrets.ldb
[2020/04/02 17:39:43.090504, 3] ../lib/util/util_runcmd.c:291(samba_runcmd_io_handler)
samba_runcmd_io_handler: Child /usr/sbin/samba_kcc exited 0
[2020/04/02 17:39:43.090585, 3] ../source4/dsdb/kcc/kcc_periodic.c:770(samba_kcc_done)
Completed samba_kcc OK
[2020/04/02 17:39:44.216277, 3] ../source4/smbd/service_stream.c:67(stream_terminate_connection)
stream_terminate_connection: Terminating connection - 'ldapsrv_call_wait_done: call->wait_recv() - NT_STATUS_LOCAL_DISCONNECT'