2017-09-14 232 views
-4

我有一個只命名爲CN = RA010-CAT-PAT-PUN的組,我如何通過使用LDAP或使用System.DirectoryServices.Protocols來獲得該組的完整名稱? 我有一個LdapConnection,如果僅使用LDAP知道其名稱/ CN,如何獲取組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; 
    } 
} 

通過使用SearchRequest,我怎樣才能獲得該組 「RA010-CAT-PAT-名符其實的」 中的distinguishedName?

在此先感謝。

+0

停止轉貼此問題。 – EJP

回答

0

使用SUBTREE_SCOPE從過濾器"cn=RA010-CAT-PAT-PUN"執行搜索,從適當的子樹開始。

但是你爲什麼只有CN?

+0

感謝您的回覆,我會嘗試相同的,我在項目中有一個要求,我將只有GroupName,因爲CN = GroupName可用,並且我希望從該特定組獲得所有用戶,以防LDAP disting的名字,這是不可能得到小組和成員,所以我轉發了這個問題(對不起,我將刪除它) –

+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);它是否正確? –

相關問題