尝试连接到 Active Directory 时Windows 服务器 2012(可能是 R2)轻量级目录访问协议,ldapsearch 会产生以下错误之一(在较长的输出末尾):
$ ldapsearch -H ldaps://my.ad.com -v -b "dc=my,dc=ad,dc=com"
...
ldap_sasl_interactive_bind_s: Can't contact LDAP server (-1)
additional info: A TLS packet with unexpected length was received.
或者
$ ldapsearch -H ldaps://my.ad.com -v -b "dc=my,dc=ad,dc=com" -D "[email protected]"
...
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
或者
$ ldapsearch -H ldaps://my.ad.com -d 1 -v -b "dc=my,dc=ad,dc=com" -D "[email protected]" -W
...
TLS: can't connect: A TLS packet with unexpected length was received..
ldap_err2string
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
SSL 证书已安装并使用 s_client 进行验证,例如:
openssl s_client -connect my.ad.com:636 -CApath /etc/ssl/certs/
...生成有效的输出结尾如下:
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES256-SHA384
Session-ID: 2938000006304A580F4FA7C47F3C0C64FCF43B83B666D24B247775E24DC6B5B1
Session-ID-ctx:
Master-Key: C835DACE990D164C2F97F594B1D6989179735CE38AD822165F7C20C99C826DEE7E91816693AA72B08ADD85EDB6493578
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1490979674
Timeout : 300 (sec)
Verify return code: 0 (ok)
---