ActiveDirectoryからパスワードをどうしてもとりたい場合には

Active Directory のパスワード変更をフックして、
divisonのアトリビュートに書き出すものとして
sha1hexfltr( http://code.google.com/p/sha1hexfltr/ )があります。

動かすには以下の手順を行います。
Active Directoryからパスワードは取り出せないので、別のアトリビュートにハッシュ化して出しておけば
パスワードを取り出すことができるので役に立つことがあります。

行ったことは以下です。

1). Microsoft Visual C++ 2008 SP1 再頒布可能パッケージ (x86) をダウンロードし、インストール
http://www.microsoft.com/downloads/details.aspx?familyid=A5C84275-3B97-4AB7-A40D-3802B2AF5FC2&displaylang=ja

2). sha1hexfltrのインストール
http://code.google.com/p/sha1hexfltr/
Windows 2003 環境だったので、sha1hexfltr.dll_32bit_win2k3  をダウンロード

3).ダウンロードしたファイルを sha1hexfltr.dll に リネームします。

4).dll を C:\WINDOWS\system32\ 以下にコピーします。( Windows 2003 32bitの場合)

5) レジストリーを編集します。
[スタート] -- [ファイル名を指定して実行] で "regedit" と入力して、レジストリーエディタを起動します。
HKEY_LOCAL_MACHINE -> SYSTEM -> CurrentControlSet -> Control -> Lsa
'Notification Packages' をダブルクリックして、'sha1hexfltr'をリストの最後に追加します。

6).マシンを再起動

7). 再起動したら以下を実行します。
・[スタート] -- [ファイル名を指定して実行]
rundll32 sha1hexfltr.dll,about と入力して、OKボタンクリック
"test this" というダイアログが出るか確認します。

次に msinfo32 と入力します。
ソフトウェア環境 -- 読み込まれているモジュール と開き
sha1hexfltrがロードされているか確認します。
ない場合はロードできていないので環境を確認して下さい。

【動作確認】

・ドメインコントローラーで、ActiveDirectory ユーザとコンピューターの画面から
  ユーザを選択し、右クリックからパスワードのリセットを実施します。
  その際に【ユーザは次回ログイン時にパスワード変更が必要】にチェックを入れておきます。

以下で説明に使っている divison内のハッシュ値は本来のものを書き換えていて
適当なものになっています。

ldapsearch で 対象ユーザのdivisionを確認すると、
値が入ったことが確認できました。

% ldapsearch -x -h 10.1.1.24 -b "dc=opensso,dc=test,dc=local" -D "cn=administrator,cn=users,dc=opensso,dc=test,dc=local" -w xxxxx "cn=testuser" division
# extended LDIF
#
# LDAPv3
# base  with scope subtree
# filter: cn=testuser
# requesting: division
#

# testuser, Users, opensso.test.local
dn: CN=testuser,CN=Users,DC=opensso,DC=test,DC=local
division: c4bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

# search reference
ref: ldap://ForestDnsZones.opensso.test.local/DC=ForestDnsZones,DC=opensso,DC=
 test,DC=local

# search reference
ref: ldap://DomainDnsZones.opensso.test.local/DC=DomainDnsZones,DC=opensso,DC=
 test,DC=local

# search reference
ref: ldap://opensso.test.local/CN=Configuration,DC=opensso,DC=test,DC=local

# search result
search: 2
result: 0 Success

# numResponses: 5
# numEntries: 1
# numReferences: 3
[mgoto@grape](0) ~/tmp

対象ユーザでログインすると、パスワード変更が求められるので、
パスワードを変更します。

ldapsearch で divisionを再度確認します。

% ldapsearch -x -h 10.1.1.24 -b "dc=opensso,dc=test,dc=local" -D "cn=administrator,cn=users,dc=opensso,dc=test,dc=local" -w xxxxx "cn=testuser" division
# extended LDIF
#
# LDAPv3
# base  with scope subtree
# filter: cn=testuser
# requesting: division
#

# testuser, Users, opensso.test.local
dn: CN=testuser,CN=Users,DC=opensso,DC=test,DC=local
division: c4eaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

# search reference
ref: ldap://ForestDnsZones.opensso.test.local/DC=ForestDnsZones,DC=opensso,DC=
 test,DC=local

# search reference
ref: ldap://DomainDnsZones.opensso.test.local/DC=DomainDnsZones,DC=opensso,DC=
 test,DC=local

# search reference
ref: ldap://opensso.test.local/CN=Configuration,DC=opensso,DC=test,DC=local

# search result
search: 2
result: 0 Success

# numResponses: 5
# numEntries: 1
# numReferences: 3

divison の値が変更されました。

ということで、動作としてはドメインコントローラー側で管理者がパスワードを変更しても、
ユーザサイドでパスワード変更した場合もフックでつかんで、divison にパスワードが入ります。