2017-03-24 25 views
0

私は全く新しいですldapサーバーが利用できません

次のコードを使用してLDAPサーバーに接続しようとしました。

PrincipalContext principalContext = new PrincipalContext(ContextType.Domain, "abcdef", "OU=abcdef,DC=avengers,DC=net"); 

"LDAPサーバーが利用できません"という例外が発生します。

ユーザー名とパスワードを追加することをお勧めする他の投稿を検索しましたが、Context.Domain、DomainおよびContainerのパラメータのみを取り込むこの特定のオーバーロードされたメソッドを使用したかったのです。

何か提案がありがとうございます。

+0

私も同様のことをしていたとき、私は 'PrincipalContext'オブジェクトの使用にも問題がありました。代わりに変数を使用することで、私はADプロパティにアクセスすることができました。 E.G: 'var context =新しいPrincipalContext(ContextType.Domain、" pc-name "、" DC = domain、DC = com "、" user "、" password "); ; UserPrincipal user = UserPrincipal.FindByIdentity(context、User.Identity.Name); ' –

答えて

0

あなたはActive Directoryを使用していないと思います。

PrincipalContextは、ADのみの場合、と正常に動作します。ディレクトリがOpenLDAPの/他の場合 、その後、

public static void Main(String[] rags) 
    { 
     //If you are not sure about username and password, leave below 2 variables as it is 
     String username="";  //Change to your username, if you have any 
     String passwd="";   //Change to your Password, if you have any 

     DirectoryEntry entry = new DirectoryEntry("LDAP://abcedf/OU=abcdef,DC=avengers,DC=net", username, passwd, AuthenticationTypes.None);   
     DirectorySearcher ds = new DirectorySearcher(entry,"ObjectClass=*"); 

     // Below statement will list all entries immediately below your BaseDN 
     foreach (DirectoryEntry c in entry.Children) 
     { 
      Console.WriteLine("{0}", c.Path); 
     } 
    } 
0

が回答ありがとうございコードの下にしてみてください。

"Domain Name"パラメータ(2番目のパラメータ)に間違った値を渡していました。ドメイン名の代わりにOU値を送信していました。

関連する問題