/// <summary> /// Efficiently fetches a named user from Sitecore. /// </summary> /// <param name="username">The name of the user to find from Sitecore.</param> /// <returns>The matching Sitecore user. Or null if user was not found.</returns> protected virtual SitecoreUser GetSitecoreUserInternal(string username) { var domain = Domain.GetDomain(_sitecoreContext.BackendDomainName); int count; var siteCoreUsers = domain.GetUsersByName(0, 1, username, out count).ToList(); return(siteCoreUsers.FirstOrDefault()); }
/// <summary> /// Returns a list of sitecoreusers for a configured domain. /// </summary> /// <remarks> /// This is a very expensive call! /// If there are around 8K users, it takes about 4 seconds on a developer computer. /// </remarks> /// <returns>List of Sitecore users</returns> protected virtual IEnumerable <SitecoreUser> GetSitecoreUsersInternal() { if (SitecoreUsers == null) { // Sites are available in web.config where you can look up the domain name for the backend, and retrieve the security domain that way. var domain = Domain.GetDomain(_sitecoreContext.BackendDomainName); var siteCoreUsers = domain.GetUsers().Where(x => x.LocalName != null); SitecoreUsers = siteCoreUsers.ToList(); } return(SitecoreUsers); }