I am trying to create a web part which shows a list of all members of a specific sharepoint group. One of the columns of the list must be SPFieldType.User. Do I need to create a SPList? When do I need to update the list? when you add a new user to the group or when the page which contains the web part reloads? what is the best solution? thank you. (I dont want to use Members web part)
3 Answers
Unfortunately there is no easy solution for doing this in the general case, because the recommended way to add people to SharePoint groups is to do it through AD-groups which can be nested, cross-domain, ...
If you make the assumption that users are only added directly to the SharePoint group, then your web part can just show the content of the SPGroup.Users property and there is no need to maintain a list for that.
SharePoint already got a list on Top Level Site for managing the users and groups called "User Information List". So you don't need to create a separate List for that.
You can create a webpart, to show all the users for the specified group. For group specification, create a custom property in webpart to specify the SharePoint Group Name.
-
Yes, I have searched on Internet to find out how do you create a Web Part which contains a columen which is SPFieldType.User, I haven't find.– MedesSep 28, 2012 at 7:40
-
May I know, why do you want the SPFieldType.User in the webpart? Sep 28, 2012 at 8:30
-
I want to have a custom Site user webpart which will be a list of all users in a specific group and one of columns must be a User type.– MedesSep 28, 2012 at 10:11
-
Please refer to This link . Here the author tries to retrieve all users from all groups.
1) you need not create a new list. 2) Modify the code in above link to suit your needs. You can specify the group name in object model or have it as a property in your wen part.
Cheers
-
Thank you for the link, my problem was how do I show users in a web part which contains spFieldType.User– MedesSep 28, 2012 at 6:47