LoginSignup
1
0

More than 5 years have passed since last update.

ldapのパスワードの有効期限を通知するためにリストを取得する検索フィルタ

Posted at

備忘録です。
アカウントロック運用が始まる前に作られた有効期限を通知するスクリプトを修正する必要があったので。

パスワードをロックされてるユーザはpwdAccountLockedTimeがつくロックされてないとつかない。
http://blog.kichise.com/2012/03/openldap-ppolicy.html

これ↓超わかりやすいなと思いました。ldap検索フィルタ式の解説。
http://infolib.lotus.com/resources/portal/8.0.0/doc/ja_jp/PT800ACD001/admin/rbug_ldapfltrxprns.html

で、アンドで否定だと以下のような感じになるようでした。
(&(属性名と比較演算子と値)(!(属性名と比較演算子と値)))

ので、shadowLastChangeだけ拾ってたのをpwdAccountLockedTimeも追加する感じになおしました。

ldapsearch -x -LLL -D "検索可能なDN" \
-w ${LDAPPASS} \
-b "ou=People,dc=hoge,dc=example,dc=com" -s sub \
'(&(shadowLastChange=*)(!(pwdAccountLockedTime=*)))' uid shadowMax shadowLastChange mail

ダブルクォートで囲むと感嘆符(!)が展開されてそこで止まるのでシングルクォートになおしました。
あと期限きれたあと延々本人にメール行く部分(書いてないですが)を管理者に行くようになおしたりなども。

以上。

参考:
ブログ ??? メモ ???: OpenLDAP ppolicy でロックされてるアカウントを検索
LDAP 検索フィルター式
man test
man mailx

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0