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

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Integrating DNN membership in external asp.net websiteIntegrating DNN membership in external asp.net website
Previous
 
Next
New Post
6/29/2009 6:17 PM
 

I am trying to call the dotnetnuke API to use membership and roles in an external asp.net website.

I added a reference to dotnetnuke.dll and tried the following:
Dim mUserRoles As New DotNetNuke.Security.Roles.RoleController

I get the following error:
The type initializer for 'DotNetNuke.Security.Roles.RoleController' threw an exception.

What am I doing wrong?

 
New Post
7/8/2009 8:35 PM
 

You will need to setup an IoC container like this.

var container = new DotNetNuke.ComponentModel.SimpleContainer("Test");
DotNetNuke.ComponentModel.ComponentFactory.Container = container;
var roleController = new DotNetNuke.Security.Roles.RoleController();

BUT

The methods on the RoleController are static so you dont need an instance so setup your container and then just use the class like

DotNetNuke.Security.Roles.RoleController.AddUserRole(user,role,portalSettings, DateTime.Now, DateTime.Now, 1, true);
 


Philip Beadle - Employee
 
New Post
6/28/2010 1:59 PM
 
I'm trying to do something like this on the Install version of DNN and every time I hit the line "if" statement below, .Net is trying to prompt me for the RoleController.vb source file. How do I resolve this? var container = new DotNetNuke.ComponentModel.SimpleContainer("UserTest"); DotNetNuke.ComponentModel.ComponentFactory.Container = container; DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController(); if (rc.GetUserRole(1, UserID, roleID) == null) { rc.AddUserRole(1, UserID, roleID, DateTime.Now, DotNetNuke.Common.Utilities.Null.NullDate); }
 
New Post
6/29/2010 6:46 PM
 

Hi anyone and everyone, please help with this...
I have an external application that's trying to add a user role to a DNN user and I already followed Philip's advice so here's my code.  btw, the RoleController does not contain static methods in my "Install" version of DNN 05.04.01

var container = new DotNetNuke.ComponentModel.SimpleContainer("Test");

DotNetNuke.ComponentModel.ComponentFactory.Container = container;

DotNetNuke.Security.Roles.RoleController rc = new DotNetNuke.Security.Roles.RoleController();

rc.AddUserRole(0, UserID, roleID, DateTime.Now, DotNetNuke.Common.Utilities.Null.NullDate);

I get an exception and so I downloaded the source code to trace it.  The very first line of RoleController.AddUserRole is
Dim objUser As UserInfo = UserController.GetUserById(PortalID, UserId)
which does
Return memberProvider.GetUser(portalId, userId)
At this time, memberProvider is Nothing so I get the "Object reference not set to an instance of an object.".

Am I supposed to do anything else to have this working?

Thanks

 
New Post
7/12/2010 11:33 AM
 
Hi Philip,

I was wondering if you ever got this code working?  I tried but it didn't work.  Please show me how.  Thanks.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...Integrating DNN membership in external asp.net websiteIntegrating DNN membership in external asp.net website


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