DNN UserController as Data Source

Jan 8, 2016 at 10:28 AM
Hi All,

Is there anyway to get DNN Users as a Data Source in 2sxc... In this case I want to get all Users who are in a Role and access the users account and profile properties.

Jan 11, 2016 at 8:31 AM
Hi Jax,

it all depends, what technique you are using, see here:

With Razor, you can use Dnn.User, it's a UserInfo Object (from the DNN API) and has a List "Roles":
Dnn.User.Roles should be an array or List<string> to use in your Razor-Template.

I'm using a special API-Controller (UserController) to get these Infos per API.
E.g. to test, if current user is in a role, or get all users of a specific role:
public bool isUserInRole(string roleName)
            bool r = PortalSecurity.IsInRole(roleName);

            if (!r)
                int pid = DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId;
                UserInfo user = UserController.Instance.GetCurrentUserInfo();
                UserInfo again = UserController.Instance.GetUserById(pid,user.UserID);
                r = again.IsInRole(roleName);

            return r;

public List<string> ByRole(string roleName)

            int pid = DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId;
            ArrayList allUsers = DotNetNuke.Entities.Users.UserController.GetUsers(pid);
            List<string> userList = new List<string>();
            foreach (UserInfo user in allUsers)

            return userList;

Do not get confused, why I'm testing for the role twice, I had some issues with GetCurrentUserInfo, thats why...

You can totally use the functions inside razor, if you like to...

BR, Daniel
Feb 22, 2016 at 4:52 PM