2011-03-21 5 views
0

우리 기관에는 636 번 포트를 통해 LDAPS를 통해 액세스하는 대형 LDAP 시스템이 있습니다.이 LDAP에 대한 IQueryable 인터페이스를 생성하여 기존 People 엔티티에 매핑하지만 문제가 있습니다.비 AD LDAP에서 IQueryable

내가 위에서 언급 했으므로 사람들은 내 최종 목표를 알기 때문에 IQueryable 영역 외부에서도 누군가가이 비 -AD LDAP에 대한 성공적인 쿼리를 실행하는 것을 도울 수 있다면 오늘 만족할 것입니다.

var url = @"ldaps://ldap.ucdavis.edu:636/uid=s1,ou=s2,dc=ucdavis,dc=edu"; 
     var password = @"something"; 

     DirectoryEntry entry = new DirectoryEntry(url); 
     entry.Password = password; 
     entry.AuthenticationType = AuthenticationTypes.Secure; 

     DirectorySearcher mySearcher = new DirectorySearcher(entry); 

     SearchResultCollection results; 

     results = mySearcher.FindAll(); 

     foreach(SearchResult resEnt in results) { 
      ResultPropertyCollection propcoll = resEnt.Properties; 

      foreach (string key in propcoll.PropertyNames) 
      { 
       foreach (object values in propcoll[key]) 
       { 
        switch (key) 
        { 
         case "sn": 
          //sb.Append(key.ToString() + "<surname>" 
          //+ values.ToString() + "</surname>"); 
          break; 
         case "cn": 
          //sb.Append(key.ToString() + "<cn>" 
          //+ values.ToString() + "</cn>"); 
          break; 
         case "name": 
          //sb.Append(key.ToString() + "<name>" 
          //+ values.ToString() + "</name>"); 
          break; 
        } 
       } 
      } 
     } 

을하지만 라인 mySearcher.FindAll()에 "알 수없는 오류"점점 계속 : 여기 (I 보안 암호, UID 및 OU를 편집 한) 지금까지 무슨이다. 여기에 명백한 문제가있는 사람이 있습니까? ou와 uid를 올바르게 지정하고 있습니까?

+0

고마워요.하지만 아무런 변화가없는 것 같습니다. – Christopher

답변

2

> 여기에 명백한 문제가 있습니까?

검색어 자체는 어디에 있습니까?

DirectorySearcher(entry); 

기본 경로를 사용하여 검색자를 초기화합니다.

"filter"속성을 "(objectClass = inetOrgPerson)"과 같은 유효한 LDAP 검색 문자열로 설정해보십시오.

또한 SearchScope를 OneLevel로 설정하십시오.

어쨌든 도움이 될 것이라고는 생각하지 않습니다.

AFAIK DirectorySearcher는 단순히 ADSI에 대한 래퍼입니다. 대신에 System.DirectoryServices.Protocols 네임 스페이스의 클래스를 사용해야합니다.이 문서를 참조하십시오. http://msdn.microsoft.com/en-us/library/bb332056.aspx

0

LDAP DN이 맞습니까? AD는 dc = acme, dc = com을 사용했지만 다른 LDAP 서버는 아마도 ou = ucdavis, o = edu를 사용할 수 있습니다.

관련 문제