0

I am querying my active directory using novell.directory.ldap.netstandard from my .net core project.

It is only bringing back a maximum of 1000 users, I know this is because the PageSize on the server is set to 1000, how can I get the code to bring back all active directory users? - I am using the async search method.

        string ldapHost = "";
        int ldapPort = ;
        string loginDN = "";
        string password = "";
        string searchBase = "";
        string searchFilter = "";
        string[] attributes = new string[] { "givenName", "sn"};

        LdapConnection ldapConn = new LdapConnection();

        ldapConn.Connect(ldapHost, ldapPort);

        ldapConn.Bind(loginDN, password);

        LdapSearchQueue queue = ldapConn.Search(searchBase, LdapConnection.SCOPE_SUB, searchFilter, attributes, false, (LdapSearchQueue)null, (LdapSearchConstraints)null);

        LdapMessage message;
        int i = 1;

        while ((message = queue.getResponse()) != null)
        {
            if (message is LdapSearchResult)
            {
                LdapEntry entry = ((LdapSearchResult)message).Entry;

                LdapAttributeSet attributeSet = entry.getAttributeSet();

                Console.WriteLine(i + " " + attributeSet.getAttribute("givenName")?.StringValue + " " + attributeSet.getAttribute("sn")?.StringValue);
                i++;
            }
        }

        ldapConn.Disconnect();
Jens
  • 67,715
  • 15
  • 98
  • 113
Stephen E.
  • 252
  • 2
  • 17

1 Answers1

-1

In LDAP terms, you need to use the page result control.

In C#, this question seems to cover it : https://stackoverflow.com/a/90668/7990687

Community
  • 1
  • 1
Esteban
  • 1,752
  • 1
  • 8
  • 17
  • 1
    I can get it to work using the DirectorySearcher when I created a new project and targeted old .net framework but DirectorySearcher isnt available in .net core yet so I have to use a 3rd party library to do it which is causing me the issue as I cannot find out how to do it. – Stephen E. May 22 '17 at 13:01
  • It seems that the control is not available in the novel lib : https://www.novell.com/coolsolutions/feature/11204.html#5.1 May be you can manage some workaround with the VLV (Virtual list view) control, but it is out of my knowledges :/ – Esteban May 22 '17 at 13:51