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  |  

telerik -- supercharge your DNN websites
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
r2i.ntegrated
 


  Sponsors  

Meet Our Sponsors

ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
Salaro -- Skins and more
OnyakTech
 


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
282 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.

 


WDK Solutions
Quality modules for the DotNetNuke community. Check out our 'wild' modules!
wdkns.com
UK - DotNetNuke providers
UK providers of DNN module development and skin package design. Oxford Information Labs provides cost-effective solutions for businesses and organisations specialising in Skin design and bespoke module development.
www.oxil.co.uk
TronixSoft
Hosting for local businesses that want more from their websites.
www.TronixSoft.com

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