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.0NullReference when deleting UserRoleNullReference when deleting UserRole
Previous
 
Next
New Post
12/15/2006 2:36 AM
 
I am wanting to remove a User from any Role in a given RoleGroup in my module.
My code is below:

            Dim roleController As New DotNetNuke.Security.Roles.RoleController

            Dim roles As String() = roleController.GetRolesByUser(UserID, PortalID)

            For Each r As String In roles
                Dim role As DotNetNuke.Security.Roles.RoleInfo = roleController.GetRoleByName(PortalID, r)
                If role.RoleGroupID = RoleGroupID Then
                    roleController.DeleteUserRole(PortalID, UserID, RoleID)
                    End If
                End If
            Next


When it hits the line 'roleController.DeleteUserRole()', I get a NullReference exception even though the PortalID, UserID and RoleID are valid.
The exception is below:

System.NullReferenceException was unhandled by user code
  Message="Object reference not set to an instance of an object."
  Source="DotNetNuke.Provider.DNNProvider"
  StackTrace:
       at DotNetNuke.Security.Membership.DNNRoleProvider.RemoveUserFromRole(Int32 portalId, UserInfo user, UserRoleInfo userRole)
       at DotNetNuke.Security.Roles.RoleController.DeleteUserRole(Int32 PortalId, Int32 UserId, Int32 RoleId)
       at AMUNC.Modules.Accommodation.AccommodationController.UpdateAccommodationRole(Int32 PortalID, Int32 UserID, Int32 RoleID, Int32 RoleGroupID)


Any ideas on what is causing the exception?
 
New Post
12/19/2006 4:40 PM
 
My bad. I was passing in the wrong UserID value.
Now all I have to deal with is the caching of the user roles which seems to be causing problems....
 
New Post
12/19/2006 5:49 PM
 

If you figure the role caching issue out let me know.

We have to dynamically assign roles at login.. it works fine on some implementations, but on our win2003 box, the roles seem to be ignored.

 
New Post
12/20/2006 4:28 AM
 
The problem I am having is that I am adding users to roles programmatically, but then I need for tabs or modules to become visible based on membership in that new role.

This only happens after about 1 minute or so.
This post is dealing with a similar area: http://www.dotnetnuke.com/Community/ForumsDotNetNuke/tabid/795/forumid/111/threadid/83632/scope/posts/Default.aspx

It looks like

DataCache.RemoveCache("GetTabPermissionsByPortal" & PortalID.ToString

removes the caching of the results of the Stored procedure. I haven't tried this out yet on my code- but it might provide some answers.

Do let me know- and if anyone from Core or with more experience dealing with these issues knows- then their contribution would be appreciated.
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0NullReference when deleting UserRoleNullReference when deleting UserRole


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