1

ADAM インスタンスをセットアップし、テスト ユーザーを追加しました。c# から Windows アカウントを使用して ADAM にバインドできますが、ADAM ユーザーのいずれかを使用してバインドできません。(ldp で adam ユーザーを正常にバインドできます) & msDS-UserAccountDisabled 属性を false に設定して、ユーザーが有効になっていることを確認しました。Windows アカウントにバインドすると、ADAM ユーザーのプロパティを正常に検索して戻すことができますが、ADAM ユーザー アカウントにバインドしようとすると、まだ認証に苦労しています。エラーが発生します。

エラー: System.Runtime.InteropServices.COMException (0x8007052E): ログオンに失敗しました: 不明なユーザー名またはパスワードが正しくありません。System.DirectoryServices.DirectoryEntry.Bind (ブール値 throwIfFail) で

私が使用しているコードは次のとおりです。

string userName = txtUserName.Text;
string password = txtPassword.Text;
string ADConnectionString = "LDAP://localhost:389/CN=sandbox,DC=ITOrg";
DirectoryEntry entry = new DirectoryEntry(ADConnectionString);

entry.Username = "myComputer\\Administrator";
entry.Password = "myPassword";
try 
{
DirectorySearcher searcher = new DirectorySearcher(entry);
searcher.Filter = "(&(objectClass=user)(CN=" + userName + "))";
SearchResultCollection result = searcher.FindAll();
if (result.Count > 0)
{
    //bind with simple bind
    using (DirectoryEntry de = new DirectoryEntry(result[0].Path, userName, password,AuthenticationTypes.None))
    {
         if (de.Guid != null) // this is the line where it dies
         {
              Label1.Text = "Successfully authenticated";
              Label2.Text = result[0].Properties["displayName"][0].ToString();
              Label3.Text = result[0].Properties["telephoneNumber"][0].ToString();
          } else 
          {
             Lable1.Text = "Unable to Authenticate";
          }
     }
}
else
{
    Lable1.Text = "UserName :" + userName + " not found"; 
}
} catch(Exception ex)
{
     Label1.Text = "Error searching: " + ex.ToString();
}

ご協力いただきありがとうございます。

4

1 に答える 1