Re: IsInRole always return fasle on secure remoting call (Framework 2.0)

Tech-Archive recommends: Fix windows errors by optimizing your registry



Thanks Luke,

So if I understand, I need t o create a WindowsPrincipal from The IPrincipal
for the IsInRole to work properly. I try to do this:

WindowsPrincipal wp = Thread.CurrentPrincipal as WindowsPrincipal;

but in this case wp is NULL, the conversion does not wotk. I tried to create
a WindowsIdentity so I could create a WindowsPricipal, but I can not find
how you get the TOKEN fron the IPrincipal (needed to construct the
WindowsIdentidy).

Any advise?

Cheers,
Eric




"Luke Zhang [MSFT]" <lukezhan@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:vfksuzMQGHA.6016@xxxxxxxxxxxxxxxxxxxxxxxx
Hello,

In your code, "aWinPrinc" is a WindowsPrincipal, but
Thread.CurrentPrincipal implements from IPrincipal, it is a
GenericPrincipal Class actually. They are not same classes yet. And the
underly arithmetic in IsInrole() method is also not same. WindowsPrincipal
will call a Windows API CheckTokenMembership() to get the result of
IsInRole(); GenericPrincipal totally rely on current Role provider.

Regards,

Luke Zhang
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



.



Relevant Pages

  • Re: Have half working
    ... post all in a second post. ... "true" for all of the IsInRole calls. ... WindowsIdentity wi = Context.User.Identity; ... IdentityReferenceCollection sids = wi.Groups; ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Have half working
    ... IsInRole() is still failing inside my ASP.NET app. ... WindowsIdentity.GetCurrent() will always return a WindowsIdentity ... IPrincipal user = Thread.CurrentPrincipal; ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: IsInRole performance issue
    ... I didn't implement my own WindowsIdentity but if I had to implement from ... You will be looking for the DevelopMentor Security Utilities link. ... > how your IsInRole implementation works? ... >> your domain controller. ...
    (microsoft.public.dotnet.security)
  • Re: IsInRole performance issue
    ... I didn't implement my own WindowsIdentity but if I had to implement from ... You will be looking for the DevelopMentor Security Utilities link. ... > how your IsInRole implementation works? ... >> your domain controller. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Problem checking users role
    ... You shouldn't need to cast the class to check IsInRole. ... IsInRole is a member of the IPrincipal interface which is ... not the WindowsIdentity class. ...
    (microsoft.public.dotnet.security)