Sitecore query/fast query for user

2019-03-02 07:20发布

Is there a way to use fast query or query to get a user by email or a custom field? I tried this but it didn't work in the Query Tool

/sitecore/user//*[@@templateid='{642C9A7E-EE31-4979-86F0-39F338C10AFB}' AND @email='abc@123.com']

标签: sitecore
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-02 08:15

You cannot query (via Sitecore Query or Fast Query) users in the User Manager because they are not items, they're actually built on ASP.NET Membership in the Core database. Instead, you can look into something like Membership.GetAllUsers() (MSDN doc) and filter the results with LINQ based on what you're looking for.

I've done something similar in Sitecore where I called Sitecore.Security.Accounts.UserManager.GetUsers() and filtered the resulting User objects by their name property. You could do something similar like this:

var matches = UserManager.GetUsers().Where(usr => usr.Profile.Email.Equals(emailToMatch));
查看更多
登录 后发表回答