-4

I have a group naming only CN=RA010-CAT-PAT-PUN , How can i get a distiguished name of this group by using LDAP , or by using System.DirectoryServices.Protocols? I have a 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;
    }
}

By using SearchRequest, How can i get the distinguishedName for the group "RA010-CAT-PAT-PUN"?

Thanks in advance.

sagar yadwad
  • 133
  • 1
  • 3
  • 11

1 Answers1

0

Execute a search with the filter "cn=RA010-CAT-PAT-PUN", using SUBTREE_SCOPE, starting from an appropriate subtree.

But why do you have only the CN?

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Thanks for your Reply,I will try the same, I have a requirement in the project that i will have only GroupName as in CN=GroupName available and i want to get all the users from that particular group, in case of LDAP, without distingished name , it is not possible to get the group and the members ,so i reposted the question(sorry for that, i will delete it) – sagar yadwad Sep 15 '17 at 06:47
  • . One question, in SearchRequest , i should give parameters like 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 response = (SearchResponse)ldap.SendRequest(searchRequest); Is this correct? – sagar yadwad Sep 15 '17 at 06:50