Problem in getting the List of user 's from ADS.
-
Hi.. I need to get the List of all the user Name from Active Directory, i used the following code.
try{
ADEntry = new DirectoryEntry("LDAP://" + Session["DominName"].ToString() + ".net", txtUserName.Text.ToString(),
txtPassword.Text.ToString(), AuthenticationTypes.Secure);nativeObject = ADEntry.NativeObject; } catch (Exception) { DirectorySearcher mySearcher = null; mySearcher = new DirectorySearcher(ADEntry); mySearcher.SearchRoot = ADEntry; mySearcher.Filter = "(&(objectClass=USER))"; mySearcher.SearchScope = SearchScope.Subtree; mySearcher.PropertiesToLoad.Add("SAMACCOUNTNAME"); mySearcher.PropertiesToLoad.Add("cn"); mySearcher.PropertiesToLoad.Add("mail"); SearchResult srh = null; srh = mySearcher.FindOne(); int intSerialNo = 1; //SearchResultCollection result = mySearcher.FindAll(); foreach (SearchResult resEnt in mySearcher.FindAll()) { resEnt.Properties\["SAMACCOUNTNAME"\]\[0\].ToString(); resEnt.Properties\["cn"\]\[0\].ToString(); resEnt.Properties\["mail"\]\[0\].ToString(); }
But it is listing Max 1000 users details but there are 2000 entries in the ADS under "user" group.. Please anyone Help me to get the list of all the 2000 user's list in ADS.. if there is a limitation for LDAP protocol.. Can any one suggest other protocol, i tried with WINNT, NDS and IIS also..
-
Hi.. I need to get the List of all the user Name from Active Directory, i used the following code.
try{
ADEntry = new DirectoryEntry("LDAP://" + Session["DominName"].ToString() + ".net", txtUserName.Text.ToString(),
txtPassword.Text.ToString(), AuthenticationTypes.Secure);nativeObject = ADEntry.NativeObject; } catch (Exception) { DirectorySearcher mySearcher = null; mySearcher = new DirectorySearcher(ADEntry); mySearcher.SearchRoot = ADEntry; mySearcher.Filter = "(&(objectClass=USER))"; mySearcher.SearchScope = SearchScope.Subtree; mySearcher.PropertiesToLoad.Add("SAMACCOUNTNAME"); mySearcher.PropertiesToLoad.Add("cn"); mySearcher.PropertiesToLoad.Add("mail"); SearchResult srh = null; srh = mySearcher.FindOne(); int intSerialNo = 1; //SearchResultCollection result = mySearcher.FindAll(); foreach (SearchResult resEnt in mySearcher.FindAll()) { resEnt.Properties\["SAMACCOUNTNAME"\]\[0\].ToString(); resEnt.Properties\["cn"\]\[0\].ToString(); resEnt.Properties\["mail"\]\[0\].ToString(); }
But it is listing Max 1000 users details but there are 2000 entries in the ADS under "user" group.. Please anyone Help me to get the list of all the 2000 user's list in ADS.. if there is a limitation for LDAP protocol.. Can any one suggest other protocol, i tried with WINNT, NDS and IIS also..
Yes, LDAP has a limit of 1000 result for a single search. To avoid that you must perform a paged search. To do that, just set the PageSize property of the DirectorySearcher object to a value greater than 0 (e.g. 500 or 750) before calling the FindAll method. The MSDN documentation for that is Here[^].
-
Yes, LDAP has a limit of 1000 result for a single search. To avoid that you must perform a paged search. To do that, just set the PageSize property of the DirectorySearcher object to a value greater than 0 (e.g. 500 or 750) before calling the FindAll method. The MSDN documentation for that is Here[^].