2019年5月6日 星期一

Windows 2012 ldaps configuration

好啦!有鑑於windows server 2008即將下課,那麼就來研究一下怎麼用server 2012把他換掉。

場景:windows server 2008 ad server,跟新安裝的server 2012。

待辦事項::
1. windows server 加入既有ad domain,並且成為網域控制站
2. 2012 ad server要支援ldaps

待辦事項一:自己google
待辦事項二:自己google

那這篇不就是廢文!?

哎呀!被你發現了!顆顆~

好啦!開玩笑地!

server 2012如何enable ldap over ssl真的請自己google,這邊要解決的是ldapsearch的問題

# ldapsearch -xLLL -H ldaps://x.x.x.x  -D "CN=Administrator,CN=Users,DC=xx,DC=xx,DC=edu,DC=tw" -w wtf1234 -b "OU=xx,DC=xx,DC= xx,DC=edu,DC=tw" "samaccountname=username1234" ProfilePath name

ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)   <<< 就是這個問題

用s_client來瞧瞧...

【2008】
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-SHA
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : ECDHE-RSA-AES256-SHA
    Session-ID: D32500004D1BBCEABB8CC65464391D94E283AEB8AE3A70CF8B7E77BD834C2A3C
    Session-ID-ctx:
    Master-Key: F96689E54A9784028E02F4C801B48407D152D21C6FD5F7702925C5C0B57D691ECD7FCE359C7DBED3F765877AF01574A3
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1557108847
    Timeout   : 300 (sec)
    Verify return code: 10 (certificate has expired)
---

好啦!我知道SSLv3要關掉好嘛!但我要先讓這些鬼東西work。

【2012】
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: B7230000C3DFC61E4C762CE28B1F5532D02406B4FE946316A915062C4A4E81EC
    Session-ID-ctx:
    Master-Key: A7786FFD87EA89D3A6D5DED482DD63C9AA8CC1BF72DFEE9ED4551742597FB19C9B066FB06BD54D7EABD8C121FF6729BE
    Key-Arg   : None
    PSK identity: None
    PSK identity hint: None
    SRP username: None
    Start Time: 1557106803
    Timeout   : 300 (sec)
    Verify return code: 21 (unable to verify the first certificate)

看起來是Protocol的差別?

來google一下
https://ubuntuforums.org/showthread.php?t=2292281

這篇2015的文章提到ldapsearch貌似有TLS v1.2的問題?我的ldapsearch好像也是2015年的版本。

那就來google一下怎麼關掉TLS v1.2
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn786418(v=ws.11)

HKLM SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols 

依照說明把TLS v1.2 disbaled後, reboot server.

來測測看!
# ldapsearch  -xLLL -H ldaps://x.x.x.x -D "CN=Administrator,CN=xx,DC=xx,DC=xx,DC=edu,DC=tw" -w password123 -b "OU=xx,DC=xx,DC=hfu,DC=edu,DC=tw" "samaccountname=user123" ProfilePath name
dn: CN=user123,OU=xx,DC=xx,DC=xx,DC=edu,DC=tw

name: user123

profilePath: \\xx\userprofile$\user123

# ./chpass.sh user123 mynewpassword my_ad_ou_                                                                                    
# chpass.sh 是改AD密碼的script                       

$CHKUSER says user123 is valid.

modifying entry "CN=user123,OU=xx,DC=xx,DC=xx,DC=edu,DC=tw"

Check User credentials via binding AD server and retriving some stuff from AD...
dn: CN=user123,OU=xx,DC=xx,DC=xx,DC=edu,DC=tw
name: user123
homeDirectory: \\xx\userprofile$\user123

profilePath: \\xx\userprofile$\user123

好了!收工!有問題請自己解決!



沒有留言:

張貼留言