Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Using array list of usersUsing array list of users
Previous
 
Next
New Post
11/26/2008 5:59 PM
 

Hello all,

I have a module where I need to be able to add all of the users currently in "RoleA" to "RoleB". I have code for adding users to a role no problem. I have the code to get a arraylist of all users currently in a role. I need help understanding how to put the two together. How can I have the AddUserRole fire for each user in the original role?

Here is what I have so far.

 

Dim roleCtlr As New DotNetNuke.Security.Roles.RoleController
            Dim objUserRoles As ArrayList = roleCtlr.GetUserRolesByRoleName(PortalId, roleName)


Got the array list of users in "roleName" Now how do I implement the code below to run on each user in the array list?


            Dim objRoles As New RoleController()
            Dim UserName1 As String = ""
            Dim user As UserInfo = UserController.GetUserByName(Me.PortalId, UserName1)
            Dim userId As Integer = user.UserID

            Dim objRoleController As New DotNetNuke.Security.Roles.RoleController
            Dim objRoleInfo As DotNetNuke.Security.Roles.RoleInfo = objRoleController.GetRoleByName(PortalId, AddVideo)
            If objRoleInfo Is Nothing Then
                selected1.Text = (selectedRole & " is not currently a member of *****.com.")
                selected2.Text = ("Ask them to sign up for a free account.")
            End If
            Dim effectiveDate As DateTime = DateTime.Now
            objRoleController.AddUserRole(PortalId, user.UserID, objRoleInfo.RoleID, effectiveDate, effectiveDate.AddDays(7.0#))
            DotNetNuke.Common.Utilities.DataCache.ClearUserCache(PortalId, user.Username)

 

For the next step of what I am doing. I also need to be able to get the email address for each of those users. How can I also pull that info from the array list.

 

Thanks in advance!

 
New Post
11/27/2008 12:31 AM
 

Rather than post code that someone might just blindly copy-and-paste (Give a man a fish...), I'll post info to help you figure things out (Teach a man to fish...).  Also I'm being too lazy to create and test any sample code solutions...

This link may help with your first question (looping through each user in your arraylist):
http://asp.net2.aspfaq.com/basic-language-constructs/for-vs-foreach.html

As for your second question:  If you're using Visual Studio and have a copy of DNN open as a project (using the "source code" DNN package and opening the included project file) then Visual Studio's "IntelliSense" feature should be active.  Using your posted code as an example, go into the code just after you've created the "userinfo" object with name "user" (Dim user As UserInfo...) and type "user." (note the dot just after "user" -- very important) to have IntelliSense show you a list of all the attributes and methods of the UserInfo object. 

If you're NOT using Visual Studio....well.....do it "old school" and locate the source code for the UserInfo object (DotNetNuke.Entities.Users.UserInfo) to see its attributes and methods.  Or just check out the following link:  http://www.howtodotnetnuke.com/tabid/120/selectedmoduleid/481/ArticleID/9/reftab/120/title/Simple_Intro_to_the_DNN_UserInfo_Class/Default.aspx

Cheers!
-mamlin


esmamlin atxgeek.me
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Using array list of usersUsing array list of users


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out