openldap+saslauthd+active directoryでpass-through authentication

AD+SUAでLDAPとして使うとか、pam_krb5使うとか、ADとLDAPでpassword syncする、とかもあるけれど
openldapのattribute使って、認証だけADにしたかったのでやってみました。

環境はCentOS 5.7。
イメージとしてはこんな感じ。
slapd => saslauthd => active directory

まず、slapdをsaslauthd経由で認証させるために
以下を追記

sasl-host       localhost
sasl-secprops   none
  • /etc/sasl2/slapd.conf (2/14修正)
pwcheck_method: saslauthd
saslauthd_path: /var/run/saslauthd/mux


お次はsaslauthd

  • /etc/sysconfig/saslauthd
SOCKETDIR=/var/run/saslauthd

MECH=ldap
FLAGS="-O /etc/saslauthd.conf"
  • /etc/saslauthd.conf
ldap_servers: ldap://dc.example.com #ADのドメインコントローラ
ldap_default_domain: example.com
ldap_search_base: dc=example,dc=com
ldap_bind_dn: sync@example.com #ADはanonymous bindできないのでbindするユーザー名
ldap_bind_pw: secret
ldap_deref: never
ldap_restart: yes
ldap_scope: sub
ldap_use_sasl: no
ldap_start_tls: no
ldap_version: 3
ldap_auth_method: bind
ldap_filter: sAMAccountName=%U
ldap_timeout: 10
ldap_cache_ttl: 30
ldap_cache_mem: 32768


slapdで管理しているユーザーのuserPassword属性を書き換えます。
{SASL}foobar@example.com


サービス再起動

# service ldap restart
# service saslauthd restart

saslauthdのテスト

# testsaslauthd -u foobar -p password
0: OK "Success."


あとはldapsearch等でbindできればOK。


pam_ldap等でも使えるけど、これだと認証しかできないのでpasswdコマンドでパスワードの変更ができない。
ADはldaps接続でないと書き込みができないけれど、ldapsにしたとして、unicodepwdをどう書き換えるかはよくわかりません。