3

Sitecore 8.1 here, I'm currently using the Sitecore AD Module 1.3.

When I search through my users from the backend using the User Manager, I can easily find all the users I want.

When I try to retrieve the from my code though, using UserManager.GetUsers(), some users - seemingly at random - don't show up at all.

Question:

Why is this happening? Is there a configuration field I'm not aware of that makes so that they don't show up when I invoke GetUsers()?

3

Basically, Sitecore uses standard .NET Membership provider.

I would suggest to check what a membership provider is configured in your solution.To do that go to:

web.config -> /configuration/system.web/membership/providers

You may have a custom override membership provider where you can have a wrong implementation of some required methods.

Just try to use the following static method of the standard Microsoft Membership provider:

Membership.FindUsersByName(usernameToMatch, pageIndex, pageSize, out totalRecords) 
New contributor
Vadzim Papko is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • I do - I am, in fact, using the AD Module. I even decompiled their DLL to try to figure out what's going wrong, but to no avail. – Emanuele Ciriachi Jan 10 at 15:16
  • I remember, I had pretty the same issue when I used Sitecore.Security.Domains.Domain.GetUsers() where PagingIterator with yield return was returning wrong amount of users. – Vadzim Papko Jan 10 at 15:41
  • So, how did you got around it? – Emanuele Ciriachi Jan 10 at 15:49
  • 1
    I used to another Sitecore.Security.Domains.Domain.GetUsersByName(some params) method that the same as above but does not use custom iterator: MembershipUserCollection usersByName = Membership.FindUsersByName(this.AccountPrefix + search, pageIndex, pageSize, out total); List<User> userList = new List<User>(); foreach (MembershipUser membershipUser in usersByName) userList.Add(User.FromName(membershipUser.UserName, false)); return (IEnumerable<User>) userList; – Vadzim Papko Jan 10 at 15:56
  • Looping through FindUsersByName did the trick, thanks! Apparently, I am unable to return all the users in one go. – Emanuele Ciriachi Jan 10 at 17:12

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.