【问题标题】:How to get a Group DistinguishedName if only its name/CN is known using LDAP?如果使用 LDAP 只知道其名称/CN,如何获取组 DistinguishedName?
【发布时间】:2017-09-14 17:01:45
【问题描述】:

我有一个仅命名为 CN=RA010-CAT-PAT-PUN 的组,如何使用 LDAP 或 System.DirectoryServices.Protocols 获得该组的专有名称? 我有一个 LdapConnection,

 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-PUN”的 distinctName?

提前致谢。

【问题讨论】:

  • 停止转发此问题。

标签: c# active-directory ldap directoryservices ldap-query


【解决方案1】:

使用过滤器 "cn=RA010-CAT-PAT-PUN" 执行搜索,使用 SUBTREE_SCOPE,从适当的子树开始。

但是为什么你只有CN?

【讨论】:

  • 感谢您的回复,我会尝试相同的,我在项目中有一个要求,即我将只有 CN=GroupName 中的 GroupName 可用,并且我想从该特定组中获取所有用户,如果是LDAP,没有专有名称,无法获取组和成员,所以我重新发布了问题(对不起,我会删除它)
  • 。一个问题,在 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);这是正确的吗?
猜你喜欢
  • 1970-01-01
  • 2022-01-17
  • 1970-01-01
  • 1970-01-01
  • 2019-01-19
  • 1970-01-01
  • 1970-01-01
  • 2015-10-04
  • 2022-08-24
相关资源
最近更新 更多