HighTechTalks DotNet Forums  

WindowsPrincipal.IsInRole throwing exceptions...

Dotnet Security microsoft.public.dotnet.security


Discuss WindowsPrincipal.IsInRole throwing exceptions... in the Dotnet Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
djkveton
 
Posts: n/a

Default WindowsPrincipal.IsInRole throwing exceptions... - 12-07-2007 , 04:42 AM






Hello,

here comes the description of the trouble:

I try to guard my code by PrincipalPermissionAttribute (but I did also try
to call IsInRole directly and even LsaLookupNames2...).
When I ask for role that exists I receive reply "true", which is good.
When I ask for role that doesn't exist, I sometimes receive "false", which
is also good, and sometimes System.Exception (trust related error), which is
not so good - especially in the case of declarative security...

Interesting observations:
- Query for roles begining with domain name (i.e. "DOMAIN\GROUP") work
always OK (returning "true" or "false")
- Query for role "Personal" would return "false"
- Query for role "PersonalPlus" would throw exception.
OS: Windows Vista in domain

Did anybody experienced (and solved) this?

Thank for your comments.

Reply With Quote
  #2  
Old   
Dominick Baier
 
Posts: n/a

Default Re: WindowsPrincipal.IsInRole throwing exceptions... - 12-08-2007 , 08:26 AM






if you omit the Domain\ part - local groups are assumed.

What exact exception do you get (including inner exception) ?

-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

Quote:
Hello,

here comes the description of the trouble:

I try to guard my code by PrincipalPermissionAttribute (but I did also
try
to call IsInRole directly and even LsaLookupNames2...).
When I ask for role that exists I receive reply "true", which is good.
When I ask for role that doesn't exist, I sometimes receive "false",
which
is also good, and sometimes System.Exception (trust related error),
which is
not so good - especially in the case of declarative security...
Interesting observations:
- Query for roles begining with domain name (i.e. "DOMAIN\GROUP") work
always OK (returning "true" or "false")
- Query for role "Personal" would return "false"
- Query for role "PersonalPlus" would throw exception.
OS: Windows Vista in domain
Did anybody experienced (and solved) this?

Thank for your comments.




Reply With Quote
  #3  
Old   
djkveton
 
Posts: n/a

Default Re: WindowsPrincipal.IsInRole throwing exceptions... - 12-09-2007 , 06:02 AM



Hi Dominick,

Quote:
if you omit the Domain\ part - local groups are assumed.
I know this. What I tried to express is that I would expect the call to
return false
for non-existent group, not exception.

Quote:
What exact exception do you get (including inner exception) ?
There is no inner exception. Just System.Exception with message (I do not
remember the exact message).
..NET Framework calls internally Win32 native function (LsaLookupNames2).
Return value of this function is C000018C (STATUS_TRUSTED_DOMAIN_FAILURE).
This coverts into windows error message "The trust relationship between the
primary domain and the trusted domain failed."

Please note interesting point, that for some calls it fails and for others
it does not. And it does not depend on whether the group exists or not, if
account that runs the request is administrator or member of the group in
question or not.

Regards

djk

Quote:
-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

Hello,

here comes the description of the trouble:

I try to guard my code by PrincipalPermissionAttribute (but I did also
try
to call IsInRole directly and even LsaLookupNames2...).
When I ask for role that exists I receive reply "true", which is good.
When I ask for role that doesn't exist, I sometimes receive "false",
which
is also good, and sometimes System.Exception (trust related error),
which is
not so good - especially in the case of declarative security...
Interesting observations:
- Query for roles begining with domain name (i.e. "DOMAIN\GROUP") work
always OK (returning "true" or "false")
- Query for role "Personal" would return "false"
- Query for role "PersonalPlus" would throw exception.
OS: Windows Vista in domain
Did anybody experienced (and solved) this?

Thank for your comments.





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.