Only 1000 of my AD entries were being returned by dsUsers,FindAll(), quick search after spending what seemed hours banging my head trying to debug where I could only access a small development DC with < 100 users...So deploy to prod server and output file appends with info, yeah the long way.
It was also only returning a portion of the properties within that 1000 too, 381 entries it told me didn't have an ipPhone field set, whereas Domain Users server tools told me that 99% were set...
Anyway, found that someone already had figured out to frig the Pagesize parameter, which for some reason got past the 1000 restriction.
// declare directory searcher
DirectorySearcher dsUsers = new DirectorySearcher(deRoot);
dsUsers.SearchScope = SearchScope.Subtree;
//OR the filter
dsUsers.Filter = "(|(objectCategory=person)(objectClass=user))";
dsUsers.PageSize = 1001;// ms limitation with shitty workaround
// define what properties you want to have loaded into your search results
dsUsers.PropertiesToLoad.Add("givenName");
dsUsers.PropertiesToLoad.Add("sn");
dsUsers.PropertiesToLoad.Add("samAccountName");
dsUsers.PropertiesToLoad.Add("ipPhone");
dsUsers.PropertiesToLoad.Add("telephoneNumber");
dsUsers.PropertiesToLoad.Add("mobile");
dsUsers.PropertiesToLoad.Add("department");
dsUsers.PropertiesToLoad.Add("l");
It was also only returning a portion of the properties within that 1000 too, 381 entries it told me didn't have an ipPhone field set, whereas Domain Users server tools told me that 99% were set...
Anyway, found that someone already had figured out to frig the Pagesize parameter, which for some reason got past the 1000 restriction.
// declare directory searcher
DirectorySearcher dsUsers = new DirectorySearcher(deRoot);
dsUsers.SearchScope = SearchScope.Subtree;
//OR the filter
dsUsers.Filter = "(|(objectCategory=person)(objectClass=user))";
dsUsers.PageSize = 1001;// ms limitation with shitty workaround
// define what properties you want to have loaded into your search results
dsUsers.PropertiesToLoad.Add("givenName");
dsUsers.PropertiesToLoad.Add("sn");
dsUsers.PropertiesToLoad.Add("samAccountName");
dsUsers.PropertiesToLoad.Add("ipPhone");
dsUsers.PropertiesToLoad.Add("telephoneNumber");
dsUsers.PropertiesToLoad.Add("mobile");
dsUsers.PropertiesToLoad.Add("department");
dsUsers.PropertiesToLoad.Add("l");
No comments:
Post a Comment