Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > System.Web.Security.Roles.GetRolesForUser() is returning no results

Reply
Thread Tools

System.Web.Security.Roles.GetRolesForUser() is returning no results

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      08-03-2008
When I call System.Web.Security.Roles.GetRolesForUser() it returns no
results even though I have roles associated with the currently logged in
user. I am able to get the username by calling
System.Web.Security.Membership.GetUser().UserName. Why am I unable to get
the Roles, and what could I need to change? The <roleManager> element in my
tag is as follows:

<roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
<providers>
<add name="CustomizedRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="logindb"
applicationName="Membership"/>
</providers>
</roleManager>

As you can see, I do have the enabled="true" attribute. Why am I having
trouble using the System.Web.Security.Roles methods? Thanks.
--
Nathan Sokalski

http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
Stan
Guest
Posts: n/a
 
      08-05-2008
On 3 Aug, 02:49, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
> When I call System.Web.Security.Roles.GetRolesForUser() it returns no
> results even though I have roles associated with the currently logged in
> user. I am able to get the username by calling
> System.Web.Security.Membership.GetUser().UserName. Why am I unable to get
> the Roles, and what could I need to change? The <roleManager> element in my
> tag is as follows:
>
> * * <roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
> * * * <providers>
> * * * * <add name="CustomizedRoleProvider"
> * * * * * * *type="System.Web.Security.SqlRoleProvider"
> * * * * * * *connectionStringName="logindb"
> * * * * * * *applicationName="Membership"/>
> * * * </providers>
> * * </roleManager>
>
> As you can see, I do have the enabled="true" attribute. Why am I having
> trouble using the System.Web.Security.Roles methods? Thanks.
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/


Nathan

If Membership works OK then there is no need to for all the extra
configuration for roles. The "CustomizedRoleProvider" name is probably
not being recognised.

Just put:

<roleManager enabled="true" />

The applicationName and connectionString will then be taken from the
MemberShip section.
 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      08-05-2008
If I use <roleManager enabled="true" /> instead of what I had before, I
receive the following error:


An exception of type 'System.Web.HttpException' occurred in System.Web.dll
but was not handled in user code

Additional information: Unable to connect to SQL Server database.


This error occurs on the following line of code:

Dim roleslist As String() = System.Web.Security.Roles.GetRolesForUser()

This is the first line of code that uses the System.Web.Security.Roles
namespace, so I am assuming that <roleManager enabled="true"/> is not
getting the connectionString from the Membership section. Here is what my
Membership section in my Web.config file looks like, since I did not include
it in my original posting:

<membership defaultProvider="CustomizedProvider">
<providers>
<add name="CustomizedProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="logindb"
applicationName="Membership"
minRequiredPasswordLength="8"
minRequiredNonalphanumericCharacters="0"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"/>
</providers>
</membership>

Any other ideas? I appreciate all suggestions and help. Thanks.
--
Nathan Sokalski

http://www.nathansokalski.com/

"Stan" <> wrote in message
news:0129a124-de28-4428-b07c-...
On 3 Aug, 02:49, "Nathan Sokalski" <njsokal...@hotmail.com> wrote:
> When I call System.Web.Security.Roles.GetRolesForUser() it returns no
> results even though I have roles associated with the currently logged in
> user. I am able to get the username by calling
> System.Web.Security.Membership.GetUser().UserName. Why am I unable to get
> the Roles, and what could I need to change? The <roleManager> element in
> my
> tag is as follows:
>
> <roleManager enabled="true" defaultProvider="CustomizedRoleProvider">
> <providers>
> <add name="CustomizedRoleProvider"
> type="System.Web.Security.SqlRoleProvider"
> connectionStringName="logindb"
> applicationName="Membership"/>
> </providers>
> </roleManager>
>
> As you can see, I do have the enabled="true" attribute. Why am I having
> trouble using the System.Web.Security.Roles methods? Thanks.
> --
> Nathan Sokalski
> njsokal...@hotmail.comhttp://www.nathansokalski.com/


Nathan

If Membership works OK then there is no need to for all the extra
configuration for roles. The "CustomizedRoleProvider" name is probably
not being recognised.

Just put:

<roleManager enabled="true" />

The applicationName and connectionString will then be taken from the
MemberShip section.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LDAP search returning too many results John Gordon Java 5 12-08-2006 09:10 PM
returning none when it should be returning a list? randomtalk@gmail.com Python 11 05-02-2006 10:26 AM
Request received well, returning it results in loss of data! Edwin Knoppert ASP .Net 5 01-06-2006 01:10 PM
sizeof struct returning unexpected results Sean C Programming 10 08-26-2004 12:56 AM
returning results with embedding Roberto Python 0 02-04-2004 05:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57