checking user role

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
6/2/2009 10:07:40 AM
Gravatar
Total Posts 2

checking user role

been looking through the dev documentation not sure if I am looking in the wrong place or not but I would like to know how I can check if a user is a member of a role ?

for example I have created 2 roles "teachers" and "students" addded my first user to teachers and my second user to students I want ether user to goto my custome module and the page to just identify if they exist in teacher or student for now

other problem I had when writing the module is I wrote it using .aspx with <!--#include virtual="/path/to/dbopen.aspx"--> to include my custom database include file but in the ascx custom module this just gives a default error and I am unable to debug so I moved the db connections to the top of the ascx file and it connects fine. is there a better way todo this as I plan to use the same database connection with multiple modules ?

is this the correct way to implment the user types I am been asked to create  ?

I do not have admin rights to my workstation is visual web developer a requiremeant (worth getting sys admin to install ?) because I have used java and vbscript this is my first time coding in C#

Thank you

 

6/2/2009 10:14:16 AM
Gravatar
Total Posts 18439

Re: checking user role

Hi,

There is no #include in ASP.NET. You must be thinking of Classic ASP

Yes, its worth installing Visual Web Developer 2008 SP1. If you are new to ASP.NET there is a lot of benefit to working with the source code to learn how to do things from existing code, like how to do data access and almost any other thing you would need to do, there are good examples of easy to read and understand code.

You can check if a user is in a role using:

using mojoPortal.Business.WebHelpers;

if(WebUser.IsInRole(rolename))

and you can check against a semi colon separatedl list of roles using if( WebUser.IsInRoles(riolestring))

Hope it helps,

Joe

6/2/2009 10:54:50 AM
Gravatar
Total Posts 2

Re: checking user role

Hi Joe,

thanks for the quick reply IsInRole worked perfect also got Visual Web Developer installing now

Thanks again

You must sign in to post in the forums. This thread is closed to new posts.