Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

AspDotNetStoreFront
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Iron Speed Designer is a software development tool for building database, reporting, and forms applications for .NET without hand-coding.
 


  Sponsors  

Meet Our Sponsors

The best choice for your web site host, email hosting, and domain registration.
CrystalTech Web Hosting™
Webhost4life, specialists in DNN hosting
Mad Development is a full service interactive agency focusing on the merge of design, technology, e-commerce, and affiliate marketing by providing total website solutions.
AspDotNetStoreFront - E-Commerce by Design - The Leading ASP.NET shopping cart platform for developers!
Click here to go to dev.live.com for Windows Live developer resources
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  How to create a role
Previous Previous
 
Next Next
New Post 5/5/2008 2:57 AM
User is offline weixiaohui
1 posts
10th Ranked


How to create a role 

Hi!

     I want to create a role then I write the follow code

            DotNetNuke.Security.Roles.RoleInfo studentRoleInfo = new DotNetNuke.Security.Roles.RoleInfo();
            studentRoleInfo.RoleName = "student";
            studentRoleInfo.IsPublic = false;
            studentRoleInfo.AutoAssignment = false;
            studentRoleInfo.PortalID = 0;
            studentRoleInfo.Description = "student";     
            bool resultRole = DotNetNuke.Security.Roles.RoleProvider.Instance().CreateRole(0, ref studentRoleInfo);

but that can't create the role "student",I don't know why.    

How to use the method "CreateRole"?

Thanks!

 
New Post 5/7/2008 8:15 PM
User is offline Ryno
289 posts
9th Ranked




Re: How to create a role 
Modified By Ryno  on 5/7/2008 11:23:26 PM)

I have a similar question that might actually help you.  Here is how I used to add a user to a "Security Role" back in DNN3.  I migrated to DNN4, however, and now this piece of code SOMETIMES assigns the user to the role and SOMETIMES it doesn't.  I have heard this is an error with DotNetNuke but I'm not sure.  Does anybody know how to programmatically assign someone to a role all the time?  I'm considering putting in a LOOP after this to see if the user IS in the role and if NOT then assign them into the role AGAIN until they are.  I'd rather not code like that since it might end up in a weird loop but....  Here is my code that sometimes works and sometimes doesn't:

CAN ANYBODY TELL ME HOW TO POST CODE SAFELY ON HERE WITHOUT THE formAT GETTING SCREWED UP?  Like a [CODE] [/CODE] method?

 

 ' Now give role access
Dim TheRoleName As String
Dim TheRoleID As Integer
If RequestInfo.InstructorPilot Then TheRoleName = "AF-IP"
If RequestInfo.StudentPilot Then TheRoleName = "UPTstud"
If (Not RequestInfo.InstructorPilot) And (Not RequestInfo.StudentPilot) Then TheRoleName = "AF-PilotSelect"
Dim RoleController As New DotNetNuke.Security.Roles.RoleController
Dim RoleInfo As New DotNetNuke.Security.Roles.RoleInfo
RoleInfo = RoleController.GetRoleByName(Me.PortalId, TheRoleName)
TheRoleID = RoleInfo.RoleID
RoleController.AddUserRole(Me.PortalId, OurUserID, TheRoleID, Null.NullDate)


I use DNN version 4.8.1
 
New Post 7/23/2008 3:52 AM
User is offline mohsinraz
4 posts
10th Ranked


Re: How to create a role 

Hi,

 I have tried to solve the problem using createrole and addrole but it is ot working in 4.x... i dont know why.

So, i have tried to insert direct to database.. and it is working..

            cmd.CommandText = "INSERT INTO Roles (PortalID, RoleName, Description,IsPublic, AutoAssignment,BillingFrequency,BillingPeriod,TrialFrequency,TrialPeriod) VALUES (" + Me.PortalId.ToString + ",'" + ri.RoleName + "', '" + ri.Description.ToString + "', 0,0,'N',1,'N',1)"

            connection1.Open()
            cmd.ExecuteNonQuery()

----Thanks

Mohsin

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  How to create a role
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


PointClick DotNetNuke Solutions
PointClick Technologies provides high-end DNN Hosting for businesses.
PointClick.Net Hosted Solutions
Active Modules, Inc.
Creators of Active Forums, the best forum module for DotNetNuke
www.activemodules.com
DotNetNuke Marketplace - Modules & Skins
The DotNetNuke Marketplace is the official e-commerce gateway for the DNN ecosystem. It's the place to buy and sell DotNetNuke modules, DotNetNuke skins, and other DNN offerings.
DotNetNuke Marketplace

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP