LDAPSEARCHコマンドでAD検索

Linuxで利用できるldapsearchでActive Directoryのユーザ情報を検索するには以下のコマンドを実行する

 ldapsearch -h <host名もしくはIPアドレス> -D ‘<ユーザ名>’ -w ‘<パスワード>’ -b ‘dc=xxx,dc=yyy’
-h・・・ADサーバのホスト名
-D・・・ログインユーザ名
-w・・・パスワード。-Wと大文字にすると対話型で入力
-b・・・検索の開始位置を指定
※注意:パスワードはシングルクォートで囲まないと、80090308: LdapErr: DSID-0C090334, comment: AcceptSecurityContext error, data 52e のエラーとなる。
エラーコード data xxxのxxxを参考にエラーの原因がおおよそわかる
エラーコード例
525 user not found
52e invalid credentials
530 not permitted to logon at this time
531 not permitted to logon at this workstation
532 password expired
533
534
account disabled
The user has not been granted the requested logon type at this machine
701 account expired
773 user must reset password
775 user account locked