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.0Programmatically add a user to a child portal.Programmatically add a user to a child portal.
Previous
 
Next
New Post
7/19/2007 5:35 AM
 

Hi all - I have a potentially tricky task... I have written some code in my V4.5.3 DNN portal to programatically add a user to a role when an event occurs, the role grants them access to a set of hidden pages on the site and I also need to grant them access to a child portal on the site

So I need to work out the code to...

a) Add a user to a child portal on my site.

b) Add a user into a security role on the child portal on my site.

A quick search has turned up nothing so far so any help would be hugely welcome.

Kevin

 
New Post
7/19/2007 10:15 AM
 

Dear All

I couldn't find an easy way to do this though the API so eventually implemented my own stored procedure which creates the necessary records in DNN tables UserPortals and UserRoles - a "little" bit of a hack I realise but works fine.  If anyone else is interested in this solution then I'll happily post a copy of the T-SQL.

Kevin

 
New Post
7/19/2007 11:35 AM
 

Adding the user to the child portal is fairly simple.  The way to add the user to the portal is to add an entry into the UserPortals table.  It is pretty basic, just five columns of data, to complete this.  I wrote a module a bit back that add the user based upon input and behind the scenes this is really all that the module does.  As for adding a user to a role, I imagine it would be a bit more difficult but along the same lines.  I haven't seen anybody acutally do this with a module or code but you would need to find out which tables adding the user into a role affects and then write to code to perform the same actions.  Just looking at the tables in the database I would say that you are going to have to add an entry in UserRoles to handle this.  It looks like this table keeps an entry for the user and the users role based upon the Id found in the Roles table.  Again, I haven't seen anybody mention that they do this but it should be possible. 

 
New Post
7/19/2007 12:54 PM
 

 

Dim user As New DotNetNuke.Entities.Users.UserInfo()
user.FirstName = "Marie"
user.LastName = "Nuked"
user.Username = "mn"
user.Email = "mail@post.com"
user.PortalID = PortalId
user.Membership.Password = "Topsecret"
If DotNetNuke.Entities.Users.UserController.CreateUser(user) = Security.Membership.UserCreateStatus.Success Then
    Dim rc As New DotNetNuke.Security.Roles.RoleController()
    Dim roleinfo As DotNetNuke.Security.Roles.RoleInfo = rc.GetRoleByName(PortalId, "MyRoleOfDesire")
    rc.AddUserRole(PortalId, user.UserID, roleinfo.RoleID, Null.NullDate)
End If

 
New Post
7/20/2007 3:30 PM
 

Hi Kevin,

I am using DotNetNuke 4.05.03 and trying to add new users through a Windows Application. Will it be possible to send me the Stored procedures.

 

Thanks

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Programmatically add a user to a child portal.Programmatically add a user to a child portal.


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