CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.dotnetnuke.custom_modules Tags:
Item Type: NewsGroup Date Entered: 1/27/2006 2:39:11 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 0 Views: 8 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
Girlnet
Asp.Net User
GetUsersInRole1/27/2006 2:39:11 AM

0/0

Is anyone else having this issue.  I'm trying to pull all the email addresses in a particular role.  I'm able to successfully get everything but the email addresses.  Am I missing something?  Here's what I've got:

Dim objRoles As New DotNetNuke.Security.Roles.RoleController
Dim objUsers As New DotNetNuke.Entities.Users.UserController
Dim userList As System.Collections.ArrayList

Dim objUser As DotNetNuke.Entities.Users.UserRoleInfo
userList = objRoles.GetUsersInRole(PortalId, "Test")
Dim sEmailName As String
Dim sEmail As String
Dim sEmailFrom As String
Dim sEmailAddFrom As String

Dim users As System.Collections.ArrayList

Dim i As Integer = 0
For i = 0 To userList.Count - 1
objUser =
CType(userList.Item(i), UserRoleInfo)

sEmail = RTrim(objUser.Email)
sEmailName = (objUser.FullName)
sEmailFrom = (UserInfo.FirstName)
sEmailAddFrom = (UserInfo.Membership.Email)

Response.Write(sEmail)
Response.Write(sEmailName)
Response.Write(sEmailFrom)

Next i

Girlnet
Asp.Net User
Re: GetUsersInRole1/27/2006 3:31:24 PM

0/0

Nothing???
imagemaker
Asp.Net User
Re: GetUsersInRole1/28/2006 4:55:14 AM

0/0

I confirmed that the Email property always comes up as Nothing in the UserRoleInfo object - the problem seems to be in the stored proceedure "GetUserRolesByUsername" which only includes all columns of the Rolls table and the calculated column "Fullname" from the Users table - either by bug or design.  Though its more inefficient, you could do a lookup on each user by objUser.UserID:

Dim rc As New Roles.RoleController
Dim uc As New DotNetNuke.Entities.Users.UserController
Dim objRoleList As ArrayList
objRoleList = rc.GetUsersInRole(PortalId, "Registered Users")
Dim sName As String = UserInfo.FirstName
Dim sEMail As String = UserInfo.Membership.Email
Dim rName As String
Dim rEMail As String
For Each objRoleInfo As DotNetNuke.Entities.Users.UserRoleInfo In objRoleList
      Dim objUser As Entities.Users.UserInfo = uc.GetUser(PortalId, objRoleInfo.UserID)
      rName = objUser.FullName
      rEMail = objUser.Membership.Email
Next

I would also suggest that your move setting the sender's name and Email outside of the loop.

 


Bill, WESNet Designs
workcontrol
Asp.Net User
Re: GetUsersInRole1/28/2006 4:55:58 AM

0/0

Email is blank because the store proc "GetUserRolesByUsername" does not have field Email selected.  If you add the email column the store proc (see field in red), the email will have value in it.  However, this is equipvalent to CORE change.

Maybe you want to try the code below where LookupUserId = UserRoleInfo.UserID

Dim objUserController As New UserController

Dim objUserInfo As UserInfo = objUserController.GetUser(PortalId, LookupUserId)

 

=============================================

set ANSI_NULLS ON

set QUOTED_IDENTIFIER ON

go

 

ALTER procedure [dbo].[GetUserRolesByUsername]

@PortalId int,

@Username nvarchar(100),

@Rolename nvarchar(50)

as

SELECT R.*,

'FullName' = U.FirstName + ' ' + U.LastName,

U.Email,

UR.UserRoleID,

UR.UserID,

UR.ExpiryDate,

UR.IsTrialUsed

FROM UserRoles UR

INNER JOIN Users U ON UR.UserID = U.UserID

INNER JOIN Roles R ON R.RoleID = UR.RoleID

WHERE R.PortalId = @PortalId

AND (U.Username = @Username or @Username is NULL)

AND (R.Rolename = @Rolename or @RoleName is NULL)

=============================================

 

 

 

 


Advanced User/Role Manager Module for DotNetNuke
Girlnet
Asp.Net User
Re: GetUsersInRole1/28/2006 3:48:30 PM

0/0

Thanks guys!  Both solutions work just fine.  I went with imagemakers suggestion as not to modify the stored proc and to avoid overwrites.

Thanks again guys - I got some really good suggestions and was toying with that more than I want to admit!

5 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

Roles.GetUsersInRole - newsgroup.asp-net-forum.general_asp-net-security ... Roles.GetUsersInRole, > ROOT > NEWSGROUP > Asp.Net Forum > general_asp.net. ... How can I used Roles.GetUsersInRole without having to refer to a TextBox or ...
cmsg cancel <[email protected]> - control.cancel - Web ... cmsg cancel &lt;[email protected]&gt;, > ROOT > NEWSGROUP > Borland Forums > control.cancel, Date: 10 ... roles.getusersinrole. microsoft ole ...
Roles.GetUsersInRole Method (System.Web.Security) Gets a list of users in the specified role. ... GetUsersInRole Method. IsUserInRole Method. RemoveUserFromRole Method. RemoveUserFromRoles Method ...
SqlRoleProvider.GetUsersInRole 方法 (System.Web.Security) 获取一个用户所属角色的列表。 ... GetUsersInRole 方法由Roles 类调用,用于在 SQL Server 数据库(在 ASP.NET 应用程序的配置文件 ... usersInRole = Roles.GetUsersInRole(RolesListBox.SelectedItem.Value) ...
Roles.GetUsersInRole - ASP.NET Forums ASP.NET Forums " General ASP.NET " Security " Roles.GetUsersInRole. Previous Next ... How can I used Roles.GetUsersInRole without having to refer to a TextBox or ...
Roles.GetUsersInRole("Administrators") - Extend It! ( Programming in ... DotNetNuke® Forums ... Re: Roles.GetUsersInRole("Administrators") Hi, ... Dim objUsersInRoles As ArrayList = objRC.GetUsersInRole(PortalId, "Administrators" ...
developerWorks : WebSphere : WebSphere Integration Developer ... Get involved in the developerWorks community by participating in discussion forums. ... We would like to use the getUsersInRole(TKIID tkiid, int role) method of the ...
GetUsersInRole Method (String) VGRolesInstance..::.GetUsersInRole Method (String) VGRolesInstance Class See ... GetUsersInRole Overload. Novalys.VisualGuard.Security.Membership Namespace ...



 
All Times Are GMT