Another approach would be to go straight to the ASP.Net Membership Provider. You should be able to execute the code below from any SitecoreController.
By Username
Membership.FindUsersByName("sitecore\\your-user-name").Cast<MembershipUser>()
.ToList().ForEach(user =>
{
var res = ExtractProperties(user);
});
By Email
Membership.FindUsersByEmail("[email protected]").Cast<MembershipUser>()
.ToList().ForEach(user =>
{
var res = ExtractProperties(user);
});
Extract Properties From User
static string ExtractProperties(MembershipUser user)
{
var p = ProfileBase.Create(user.UserName, true);
string result = string.Empty;
result += $"FullName:{p["FullName"]} ";
result += $"UserName:{user.UserName} ";
result += $"Email:{user.Email} ";
result += $"ProfileItemId:{p["ProfileItemId"]} ";
foreach (var item in p["SerializedData"] as Dictionary<string, string>)
{
result += $"{item.Key}:{item.Value} ";
}
return result;
}
If you look at the aspnet_Profile table in the core database, you will see PropertyNames field. This will show you any additional properties that are being stored. You can then access them using p["some other profile property"]
in your code.
Credit to this post that pointed me in the direction:
https://stackoverflow.com/questions/2732337/need-a-quick-way-to-mass-update-propertyvaluesbinary-field-for-all-users