Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Roles.IsUserInRole maps call to GetRolesForUser... Why?

Reply
Thread Tools

Roles.IsUserInRole maps call to GetRolesForUser... Why?

 
 
=?Utf-8?B?QmVuIFIu?=
Guest
Posts: n/a
 
      03-20-2006
Hi,

The documentation for RoleProvider.IsUserInRole states:

"The IsUserInRole method is called by the IsUserInRole method of the Roles
class and the IsInRole method of the RolePrincipal class to determine whether
the current logged-on user is associated with a role from the data source for
the configured ApplicationName."

I put breakpoints on every method in my derived custom roleprovider, and
make a call in my webpage to Roles.IsUserInRole. The method GetRolesForUser
is called, while IsUserInRole is not. The runtime seems to take the array of
strings and search the list for the correct role. Why is it doing this extra
work when I created an implimentation to do this myself? Why did I bother to
do this then? When is RoleProvider.IsUserInRole called? Is this a
documentation defect?

-Ben
 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      03-20-2006
Why do men have nipples?

<%= Clinton Gallagher

"Ben R." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> The documentation for RoleProvider.IsUserInRole states:
>
> "The IsUserInRole method is called by the IsUserInRole method of the Roles
> class and the IsInRole method of the RolePrincipal class to determine
> whether
> the current logged-on user is associated with a role from the data source
> for
> the configured ApplicationName."
>
> I put breakpoints on every method in my derived custom roleprovider, and
> make a call in my webpage to Roles.IsUserInRole. The method
> GetRolesForUser
> is called, while IsUserInRole is not. The runtime seems to take the array
> of
> strings and search the list for the correct role. Why is it doing this
> extra
> work when I created an implimentation to do this myself? Why did I bother
> to
> do this then? When is RoleProvider.IsUserInRole called? Is this a
> documentation defect?
>
> -Ben



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmVuIFIu?=
Guest
Posts: n/a
 
      03-20-2006
Anyone have a helpful answer?

"clintonG" wrote:

> Why do men have nipples?
>
> <%= Clinton Gallagher
>
> "Ben R." <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > The documentation for RoleProvider.IsUserInRole states:
> >
> > "The IsUserInRole method is called by the IsUserInRole method of the Roles
> > class and the IsInRole method of the RolePrincipal class to determine
> > whether
> > the current logged-on user is associated with a role from the data source
> > for
> > the configured ApplicationName."
> >
> > I put breakpoints on every method in my derived custom roleprovider, and
> > make a call in my webpage to Roles.IsUserInRole. The method
> > GetRolesForUser
> > is called, while IsUserInRole is not. The runtime seems to take the array
> > of
> > strings and search the list for the correct role. Why is it doing this
> > extra
> > work when I created an implimentation to do this myself? Why did I bother
> > to
> > do this then? When is RoleProvider.IsUserInRole called? Is this a
> > documentation defect?
> >
> > -Ben

>
>
>

 
Reply With Quote
 
clintonG
Guest
Posts: n/a
 
      03-20-2006
Sorry, it sounded to me like you were asking a philosophical question.

<%= Clinton Gallagher

"Ben R." <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Anyone have a helpful answer?
>
> "clintonG" wrote:
>
>> Why do men have nipples?
>>
>> <%= Clinton Gallagher
>>
>> "Ben R." <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Hi,
>> >
>> > The documentation for RoleProvider.IsUserInRole states:
>> >
>> > "The IsUserInRole method is called by the IsUserInRole method of the
>> > Roles
>> > class and the IsInRole method of the RolePrincipal class to determine
>> > whether
>> > the current logged-on user is associated with a role from the data
>> > source
>> > for
>> > the configured ApplicationName."
>> >
>> > I put breakpoints on every method in my derived custom roleprovider,
>> > and
>> > make a call in my webpage to Roles.IsUserInRole. The method
>> > GetRolesForUser
>> > is called, while IsUserInRole is not. The runtime seems to take the
>> > array
>> > of
>> > strings and search the list for the correct role. Why is it doing this
>> > extra
>> > work when I created an implimentation to do this myself? Why did I
>> > bother
>> > to
>> > do this then? When is RoleProvider.IsUserInRole called? Is this a
>> > documentation defect?
>> >
>> > -Ben

>>
>>
>>



 
Reply With Quote
 
Erik Funkenbusch
Guest
Posts: n/a
 
      03-20-2006
On Mon, 20 Mar 2006 06:50:19 -0800, Ben R. wrote:

> "The IsUserInRole method is called by the IsUserInRole method of the Roles
> class and the IsInRole method of the RolePrincipal class to determine whether
> the current logged-on user is associated with a role from the data source for
> the configured ApplicationName."


The first part is correct, the second part is incorrect. IsUserInRole is
called by the IsUserInRole method of the Roles class when you are looking
up a user who is not the current user.

When calling IsInRole for the current user, the RolePrincipal class calls
GetRolesForUser because it caches all the users roles internally, so it
only has to do this lookup once. It cannot do this if it calls
IsUserInRole.

> Why is it doing this extra work when I created an implimentation to do
> this myself? Why did I bother to do this then? When is
> RoleProvider.IsUserInRole called? Is this a documentation defect?


See above. Looks like a documentation defect. Most likely, the caching
was added late in the product cycle, and the documentation was never
updated.
 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-21-2006
Hi Ben,

Based on my research , the document does have something inconsistent with
the actual behavior. I think Erik is right. The
RoleProvider.IsUserInRole(username, password) is used for checking roles
for a given user which is not the current loggon user(for current logon
user, it also use the Principal.IsInRole instead). And for RolePrincipal,
it always use the GetRolesForUser to cache the roles and do the role
checking among the cached role list.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

 
Reply With Quote
 
=?Utf-8?B?QmVuIFIu?=
Guest
Posts: n/a
 
      03-23-2006
Hi Steve,

I want to thank both you and Eric for helping me to confirm my suspicion. Is
there a formal channel that I need to follow to officially report this defect?

-Ben

"Steven Cheng[MSFT]" wrote:

> Hi Ben,
>
> Based on my research , the document does have something inconsistent with
> the actual behavior. I think Erik is right. The
> RoleProvider.IsUserInRole(username, password) is used for checking roles
> for a given user which is not the current loggon user(for current logon
> user, it also use the Principal.IsInRole instead). And for RolePrincipal,
> it always use the GetRolesForUser to cache the roles and do the role
> checking among the cached role list.
>
> Regards,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>

 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-24-2006
Thanks for your followup Ben,

Sure, you can submit this detect or any other comments about the document
issue in the MSDN product feedback center:

http://lab.msdn.microsoft.com/produc...k/default.aspx

your feedback will be really appreciated!

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.

 
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
MSN maps vs. Google maps Ralph Fox NZ Computing 0 07-30-2007 10:30 AM
STL: Map of maps possible, but no multi-map of maps? Workarounds? Marcus C++ 2 12-09-2005 06:34 AM
Firefox & Google Maps Help Sam Firefox 3 06-11-2005 08:24 PM
std::maps within std::maps -- optimisation Simon Elliott C++ 4 03-10-2005 10:11 AM
Can't draw new maps mapmaker Firefox 2 10-22-2004 03:31 AM



Advertisments