0

I'm using SQL Role Provider and to get a list of users within the 'Admin' Role, I'm using the below code:

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

This gives me a list of AD username.

How do I get the users full name (i.e. First Name + Last Name).

Any advice appreciated!

viv_acious
  • 2,429
  • 9
  • 34
  • 55

1 Answers1

0

try something like this.

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;

            }
        }
Jalpesh Vadgama
  • 13,653
  • 19
  • 72
  • 94