パスワード有効期限と、アカウントロック状態の取得方法

search:web:passwordExpirationDate
 アカウントロック状態: isAccountLocked
 ※ それぞれWinNT接続でADSIを利用して取得します。
   PG内では、ポリシーは特に取得しません。

LDAP
 パスワード有効期限: passwordExpirationTime
 アカウントロック状態:
  リトライ回数(passwordRetryCount)がパスワードの最大失敗回数以上かつ、
  リトライ回数リセット日時(retryCountResetTime)が、判定ロジックの
  動作しているマシンのシステム日時より大きい場合、ロックアウト中とします。
  ※ ポリシーのパスワードの最大失敗回数(passwordMaxFailure)を利用します。
    ポリシーは、configファイルに定義されているパス
    (cn=Password Policy,cn=config)から 取得を行います。** .net の System.DirectoryService から、ADSIを使ってプロパティを取得する方法


using (DirectoryEntry baseEntry = new DirectoryEntry())
{
string _user = "user";
string _password = "pass";
string _server = "serverName";

//WinNTプロバイダでないと駄目
baseEntry.Username = _user;
baseEntry.Password = _password;
baseEntry.Path = "WinNT://" + _server.Trim() + "/" + userID.Trim() + ",user";

Object ads = baseEntry.NativeObject;
Type type = ads.GetType();

object isAccountLocked = type.InvokeMember(
"IsAccountLocked",
BindingFlags.GetProperty,
null,
ads,
null);

object passwordExpirationDate = type.InvokeMember(
"PasswordExpirationDate",
BindingFlags.GetProperty,
null,
ads,
null);

MessageBox.Show(isAccountLocked.GetType().ToString() + ": " + isAccountLocked.ToString());
MessageBox.Show(passwordExpirationDate.GetType().ToString() + ": " + passwordExpirationDate.ToString());
}