Developer forum

Forum » Development » frontend user groups

frontend user groups


Reply


How can I get the backend user groups using DW API?


I used the following query but I want to use the API to get the same result.
 
* from accessUser where accessUserType=11 OR accessUserType=2 ORDER BY AccessUserUserName

 

select


Replies

 
Reply

Hi Humberto,

Use the new UserManagement (available from Dynamicweb 7) to enum the groups:

        private void test()
        {
            Dynamicweb.Modules.UserManagement.User user = new Dynamicweb.Modules.UserManagement.User("username");
            foreach (Dynamicweb.Modules.UserManagement.Group group in user.Groups)
            {
                Base.w(group.Name);
            }
        }


Regards /Snedker


 
 
Reply

Oh, misunderstood you. Thought you wanted all the groups of a user - but you just want all groups. But not much difference to the basics:


        private void test()
        {
                       Dynamicweb.Modules.UserManagement.GroupCollection gc = Dynamicweb.Modules.UserManagement.Group.GetGroups();
            foreach (Dynamicweb.Modules.UserManagement.Group grp in gc)
            {
                Base.w(grp.Name);
            }
 


 
Reply

Thanks for your reply!

Just to know if I'm rigth, to see if is an extranet group I use the property

AllowBackend




Dynamicweb.Modules.UserManagement.

 

{

GroupCollection gc = Dynamicweb.Modules.UserManagement.Group.GetGroups();foreach (Dynamicweb.Modules.UserManagement.Group grp in gc)

if

(!grp.AllowBackend)//false if is extranet group

 

}

Base.w(grp.Name);
 
Reply
Hi Humberto

The AllowBackend property is a boolean that indicates if a user hqas the right to log into the backend of Dynamicweb (the admin area).

When set on a group all users of that group is allowed backend login.

 - Lasse
 
Reply
Instead of looking at the backend property, try this:

                if (grp.GetPropertyName("AccessUserType").ToString().Equals("2"))
                { 
                    Base.w("This is an Extranet group for users.");
                }
                else
                {
                    Base.w("This is NOT an Extranet group for users.");
                }

In special cases you may want to include other UserTypes.


Regards /Snedker


 

 

You must be logged in to post in the forum