2017-09-14 21 views
-4

그룹 이름이 CN = RA010-CAT-PAT-PUN입니다. LDAP를 사용하거나 System.DirectoryServices.Protocols를 사용하여이 그룹의 고유 이름을 어떻게 얻을 수 있습니까? 나는 LdapConnection이 는 SearchRequest에를 사용하여LDAP를 사용하여 이름/CN 만 알고있는 경우 Group DistinguishedName을 얻는 방법은 무엇입니까?

public LdapConnection GetLdapConnection() 
{ 
    _ldapDirectoryIdentifier = new LdapDirectoryIdentifier(_currentDomain, _defaultPort); 
    return new LdapConnection(_ldapDirectoryIdentifier); 
} 
public void GetLdapConnectionForusers() 
{ 
    try 
    { 
     _ldapConnectionUsers = GetLdapConnection(); 
     _ldapConnectionUsers.AuthType = AuthType.Basic; 
     _ldapConnectionUsers.SessionOptions.SecureSocketLayer = false; 
     if (_communicationSecurity == 1) 
      _ldapConnectionUsers.SessionOptions.VerifyServerCertificate = verifyCertificateCallBack; 
     NetworkCredential network = new NetworkCredential(_userName, _password); 
     _ldapConnectionUsers.Bind(network); 
     IsLdapConnectionEstabilished = true; 

    } 
    catch (Exception ex) 
    { 
     IsLdapConnectionEstabilished = false; 
     throw; 
    } 
} 

는 어떻게 그룹 "RA010-CAT-PAT-PUN"에 대한 distinguishedName을받을 수 있나요?

미리 감사드립니다.

+0

이 질문에 대한 답변을 다시 작성하십시오. – EJP

답변

0

적절한 하위 트리부터 SUBTREE_SCOPE를 사용하여 "cn=RA010-CAT-PAT-PUN" 필터를 사용하여 검색을 실행하십시오.

하지만 왜 CN 만 갖고 있습니까?

+0

답장을 보내 주셔서 감사합니다. 동일한 답변을 해 주셔서 감사합니다. 프로젝트의 요구 사항이 CN = GroupName과 같이 GroupName 만 사용할 수 있으며, LDAP의 경우 해당 그룹의 모든 사용자를 가져오고 싶습니다. 분명한 이름, 그것은 그룹과 회원을 얻을 수 없습니다, 그래서 나는 질문을 재 게시 (미안 해요, 내가 그것을 삭제합니다) –

+0

. 한 가지 질문은 SearchRequest에서 다음과 같은 매개 변수를 지정해야합니다. var filter = String.Format ("(& (objectCategory = Group) (CN = {0}))", "RA010-CAT-PAT-PUN"); SearchRequest searchRequest = new SearchRequest (null, filter, System.DirectoryServices.Protocols.SearchScope.Base, "DistinguishedName"); SearchResponse 응답 = (SearchResponse) ldap.SendRequest (searchRequest); 이 올바른지? –