tags:

views:

20

answers:

1

Hello,

My query is i want to store a list of users from sharepoint site in string.

i have sp_user group that contain all the user of sp_group. I have another group Moss_2007Admin that have admin users. How can i get all users name e.g. "Domain\username;Domain\username1;Domain\username2" into string type variable that i am going to use in my custom webpart.

Please help on this. Thanks.

A: 

Top of my head and have not checked in compiler :-

private string listUsers(SPGroup group)
{
   StringBuilder sb = new StringBuilder()
   foreach (SPUser user in group)
      sb.AppendFormat("{0};",user.LoginName);

   return sb.ToString();
}

See SPUser

Ryan
Thanks a lot Ryan its works fine.