Developer forum

Forum » CMS - Standard features » List groups and users from extranet

List groups and users from extranet

Peter Klünder
Reply

Hi all smart people

I have been trying to list users within groups and at the same time list the groups, but can't seem to get it to work. I'm pretty sure it was possible but have tried almost every possible solution.

  • group 1
    • user 1
    • user 2
    • user 3
  • group 2
    • user 1
    • user 2
    • user 3
  • and so on

There is no loop within the groups loop that lets you list the users within the groups.
it is possible to view the users by clicking on the group, but I would like to list them all on the same list.

Hopefully someone can say "you just forgot this setting" or have a guide/code to do it "standard templates(html) or razor"

Best regards

Peter


Replies

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi,

It seems not to be possible in regular way using 'Groups' or 'AllGroups' loops since they do not have appropriate sub-loop to render user inside the loops. It's possible to output sub-groups and users inside them using the loops & 'AllUsers' loop with 'Hierarchy' option checked but it will be other structure agaisnt the one shown above..  

BR, Oleg QA

 
Peter Klünder
Reply

Hi Oleg

I can't find anyway to list groups with connected users, I can list users and groups separately but not together. The GroupID is not even visible on the user loop.

The hierarchy and groups list just lists as the others for me that is.

I'll see if I can make a "cheat" way to do it insted of standard loops.

BR
Peter

 
Oleg Rodionov Dynamicweb Employee
Oleg Rodionov
Reply

Hi,

Yup. So, please, comment it you are able to provide an extra way fits your conditions.

BR, Oleg QA

 
Morten Snedker Dynamicweb Employee
Morten Snedker
Reply
This post has been marked as an answer

Hi,

Below is the full content of a cshtml in the Designs\[DesignFolder]\Paragraph folder. This will list all users that are member of any of the groups in list myGroupFilter. Ditch the list check to simply list all extranet groups and their users.

@{
 List<string> myGroupFilter = new List<string>() { "Jedi Council", "Master", "Apprentices" };
 <h2>--- My selected groups and their users ---</h2>
 foreach (var group in Dynamicweb.Security.UserManagement.Group.GetGroups())
 {
    if (myGroupFilter.Contains(group.Name))
    {
       <h3>@group.Name</h3>
       <ul>
       @foreach (var user in Dynamicweb.Security.UserManagement.User.GetUsersByGroupID(group.ID))
       {
          <li>@user.Name (@user.UserName)</li>
       }
       </ul>
    }
 }
}


Setup a new paragraph on a page, and have the paragraph template point to the cshmtl file.

At the time of writing this, the result can be seen at http://msn.dev01.dynamicweb.dk/standard/login

BR
Snedker

 

Votes for this answer: 1
 
Peter Klünder
Reply

Hi Morten

This is exactly what I was looking for, just removed some groups that should not be visible, and the list is working perfectly

Thank you very much for the assistance :o)

BR
Peter

 
Stephen Anthony Jackson
Stephen Anthony Jackson
Reply

Is it possible to get custom user fields out of such a loop? I am using the GetGroups() function but calling GetString  e.g. group.GetString(Tag) or GetString("tag") etc either throws an error (the first), or just blank data

 

You must be logged in to post in the forum