当前位置: 动力学知识库 > 问答 > 编程问答 >

sitecore6 - Sitecore 6 export user list

问题描述:

Is there a repeatable way to export a list of users from the user manager. I've been through the 6.2 docs and online with no success.

网友答案:

Sitecore's user management is built on ASP.NET membership, so you can use the standard ASP.NET classes to access users. The question "Sitecore query/fast query for user" might help a bit.

Here's some sample code to get you started:

var users = Sitecore.Security.Accounts.UserManager.GetUsers();
网友答案:

The easiest/quickest way I've found is to use the user manager's serialization function. I think you've been able to do it since v6. Here's the documentation.

网友答案:

The Sitecore.Security.Domains.Domain class has a GetUsers() method, if you need to conveniently list only the users in a specific security domain.

网友答案:

I ran across the same issue, and used Mark's suggestion. Heres my (hacked together) code

    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder output = new StringBuilder();
        var users = Sitecore.Security.Accounts.UserManager.GetUsers();
        foreach (Sitecore.Security.Accounts.User item in users)
        {
            string email = "";
            if(!string.IsNullOrEmpty(item.Profile.Email) ){
                email = item.Profile.Email;
            }
            output.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td></tr>",
                    item.DisplayName.ToString(),
                    email,
                    item.Profile.Comment
                  );
        }
        showusers.Text = output.ToString();
    }

Notice that the default sitecore user fields make it in there, they're just in .Profile

分享给朋友:
您可能感兴趣的文章:
随机阅读: