Home All Groups Group Topic Archive Search About

Check for certian privileges

Author
12 May 2005 4:36 PM
john conwell
I need to check if the user of the app has IO and Registy rights.  How do I
"Assert" that the current user of a WinForm app has these rights?

Thanks,
John

Author
12 May 2005 5:24 PM
john conwell
Let me expand on my question.  From what i understand CAS checks if the
calling assembly has rights to a certian resource.  But what about plain ole
fashioned user rights?  Does CAS check that too?  If the assembley has full
trust, but the user does not have rights to the registry, how can I check if
the user has rights or not?

Show quoteHide quote
"john conwell" wrote:

> I need to check if the user of the app has IO and Registy rights.  How do I
> "Assert" that the current user of a WinForm app has these rights?
>
> Thanks,
> John
Are all your drivers up to date? click for free checkup

Author
12 May 2005 5:41 PM
Joe Kaplan (MVP - ADSI)
CAS does not check NT security.  It checks the rights of the code to do
certain operations, not the user running the code.

The easiest and most reliable way to check check access to NT protected
resources is to try to open them and catch the UnauthorizedAccessException
that might happen.  If you want to do this programmatically, you probably
want to be looking at p/invoke on the AccessCheck API function.

Joe K.

Show quoteHide quote
"john conwell" <johnconw***@discussions.microsoft.com> wrote in message
news:F8DD2019-35BD-4E53-BBD4-0AD588A231A1@microsoft.com...
> Let me expand on my question.  From what i understand CAS checks if the
> calling assembly has rights to a certian resource.  But what about plain
> ole
> fashioned user rights?  Does CAS check that too?  If the assembley has
> full
> trust, but the user does not have rights to the registry, how can I check
> if
> the user has rights or not?
>
> "john conwell" wrote:
>
>> I need to check if the user of the app has IO and Registy rights.  How do
>> I
>> "Assert" that the current user of a WinForm app has these rights?
>>
>> Thanks,
>> John
Author
12 May 2005 6:16 PM
john conwell
Thats what I was afraid of. I am really under the belief that using try/catch
to control process flow is BAD practice, but I dont think I have another
choice.

Show quoteHide quote
"Joe Kaplan (MVP - ADSI)" wrote:

> CAS does not check NT security.  It checks the rights of the code to do
> certain operations, not the user running the code.
>
> The easiest and most reliable way to check check access to NT protected
> resources is to try to open them and catch the UnauthorizedAccessException
> that might happen.  If you want to do this programmatically, you probably
> want to be looking at p/invoke on the AccessCheck API function.
>
> Joe K.
>
> "john conwell" <johnconw***@discussions.microsoft.com> wrote in message
> news:F8DD2019-35BD-4E53-BBD4-0AD588A231A1@microsoft.com...
> > Let me expand on my question.  From what i understand CAS checks if the
> > calling assembly has rights to a certian resource.  But what about plain
> > ole
> > fashioned user rights?  Does CAS check that too?  If the assembley has
> > full
> > trust, but the user does not have rights to the registry, how can I check
> > if
> > the user has rights or not?
> >
> > "john conwell" wrote:
> >
> >> I need to check if the user of the app has IO and Registy rights.  How do
> >> I
> >> "Assert" that the current user of a WinForm app has these rights?
> >>
> >> Thanks,
> >> John
>
>
>
Author
12 May 2005 8:18 PM
Joe Kaplan (MVP - ADSI)
I totally agree.  However, in this case, the only way to be 100% sure is to
try it.

AccessCheck is viable though and might not be that hard to do.  Check
pinvoke.net to see if anyone has already written a wrapper.

Even if you use AccessCheck to verify access, the ACL on the object could
certainly change between the time you check it and the time you go to access
it, so you still need the try/catch.  The resource could also get deleted
out from under you for that matter.

Best of luck,

Joe K.

Show quoteHide quote
"john conwell" <johnconw***@discussions.microsoft.com> wrote in message
news:733DF9E8-70A0-408E-B9BD-CDF1E4C6013A@microsoft.com...
> Thats what I was afraid of. I am really under the belief that using
> try/catch
> to control process flow is BAD practice, but I dont think I have another
> choice.
>
> "Joe Kaplan (MVP - ADSI)" wrote:
>
>> CAS does not check NT security.  It checks the rights of the code to do
>> certain operations, not the user running the code.
>>
>> The easiest and most reliable way to check check access to NT protected
>> resources is to try to open them and catch the
>> UnauthorizedAccessException
>> that might happen.  If you want to do this programmatically, you probably
>> want to be looking at p/invoke on the AccessCheck API function.
>>
>> Joe K.
>>
>> "john conwell" <johnconw***@discussions.microsoft.com> wrote in message
>> news:F8DD2019-35BD-4E53-BBD4-0AD588A231A1@microsoft.com...
>> > Let me expand on my question.  From what i understand CAS checks if the
>> > calling assembly has rights to a certian resource.  But what about
>> > plain
>> > ole
>> > fashioned user rights?  Does CAS check that too?  If the assembley has
>> > full
>> > trust, but the user does not have rights to the registry, how can I
>> > check
>> > if
>> > the user has rights or not?
>> >
>> > "john conwell" wrote:
>> >
>> >> I need to check if the user of the app has IO and Registy rights.  How
>> >> do
>> >> I
>> >> "Assert" that the current user of a WinForm app has these rights?
>> >>
>> >> Thanks,
>> >> John
>>
>>
>>

Bookmark and Share