2017-03-24 1 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광고 만과 잘 작동합니다. 디렉토리는 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

이 응답 해 주셔서 감사합니다 코드를 아래에보십시오.

"도메인 이름"매개 변수 (두 번째 매개 변수)에 잘못된 값이 전달되었습니다. 도메인 이름 대신 OU 값을 보냈습니다.

관련 문제