【问题标题】:Get full name of users from GetUsersInRole从 GetUsersInRole 获取用户的全名
【发布时间】:2014-04-08 13:11:33
【问题描述】:

我正在使用 SQL 角色提供程序并获取“管理员”角色中的用户列表,我使用以下代码:

string[] list = Roles.GetUsersInRole("Admin");

这给了我一个 AD 用户名列表。

如何获取用户全名(即名字 + 姓氏)。

任何建议表示赞赏!

【问题讨论】:

    标签: asp.net active-directory roles roleprovider asp.net-roles


    【解决方案1】:

    试试这样的。

    List<MembershipUser> users = Roles.GetUsersInRole("Admin").Select(Membership.GetUser).ToList();
            var profiles = ProfileManager.GetAllProfiles(ProfileAuthenticationOption.All);
            foreach (var member in users)
            {
                var profile = profiles[member.UserName];
                ProfileCommon profileCommon = Profile.GetProfile(profile.UserName);
    
                if (profileCommon != null)
                {
                    string UserId = (Guid) member.ProviderUserKey;
                    string FirstName = profileCommon.FirstName;
                    string LastName = profileCommon.LastName;
    
                }
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-18
      • 2019-04-15
      • 2019-09-15
      • 2013-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多