How can I find out whether a user has permissions to see a page or not?

From: Christopher Zacharias (christopher_zacharias@hotmail.com)
Date: 07/31/02


From: "Christopher Zacharias" <christopher_zacharias@hotmail.com>
Date: Wed, 31 Jul 2002 12:53:32 -0700


Hello,

I too was looking for an answer to a similar question
before (at least I think that is the case). First off,
let me explain my situation as it is hopefully the same or
similar for you.

I am developing an intranet and I wanted a menu system
that will dynamically determine if a user has access to a
particular file that a menu item links to. If he doesn't,
then don't show the menu item. It would streamline the
interface and prevent would-be deviants from knowing of
areas of the site outside of their respective roles.

My system is run behind Windows Authentication. I turned
on Impersonation such that any threads that my ASP page
creates carry along the user's identity token.

Ok. So the server is configured at that point. I tried
to research ways of determining URL authentication
using .NET and the web.config file but ultimately gave up
on it. Not that it is impossible or anything, its just I
opted to just map the path of the URL I wanted to test and
then attempt to determine if the user has permission to
access the local file (aka an ACL check).

I couldn't really find anything that would perform an
access check on a file from within .NET (without actually
trying to open the file itself). I was able to find the
following code in VB on the following website
(http://www.freevbcode.com/ShowCode.asp?
ID=4318&NoBox=True). It demonstrates how to determine if
the current user (impersonated by the ASP process in my
case) has specific access to a given file. I had to use
it as a reference to write some Win32/managed C++ code
that would interface with my C# and VB.NET code base for
the intranet.

Check out the Win32 functions GetFileSecurity() and
AccessCheck() for details. If you want to drop me an
email, I can probably send you the portion of managed C++
I wrote to do the ACL check. Its essentially identical to
the VB code, only in C++ with managed extensions to make
it work in .NET.

If enough people are interested, I might see if I can find
a web server somewhere to deploy my website (which is LAN
based at home right now =) ) and subsequently post the DLL
and the source code for it.

- Christopher Zacharias
  christopher_zacharias@hotmail.com

>-----Original Message-----
>Hi all,
>
>I'm working in a Web App that might be used for several
users, with
>different permissions. I'm using web.config files in
order to grant/deny the
>access to those pages I want to protect, and it works
just fine so far.
>
>Now what I want to do is render the menu as a user
control or such, but I
>need to know what pages the current user is allowed to
see, and I think
>there must be some way to find this out by checking the
web.config file's
>hierarchy somehow, but I'm not sure if there's another
way to solve it. The
>WMI classes exposed by the .NET Framework could be
helpful as well, but in
>[1] states these clases possibly have a bug.
>
>[1]
>http://discuss.develop.com/archives/wa.exe?
A2=ind0207C&L=DOTNET-WEB&D=0&I=-3
>&P=6926
>
>
>Regards,
>
>
>Ramiro Calderon
>rcrdev@hotmail.com
>
>
>.
>



Relevant Pages

  • Re: Kein CopyFolder unter .NET ?!
    ... Zum einen, zum anderen kann man auch in ASP.NET alles per Notepad schreiben, wenn man unbedingt will. ... ASP website to a remote web server as making an off-site backup of the code. ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • RE: Multiple Spoofed HTTP Requests
    ... If you can't view the return packets that you have no ... idea what the web server chose as its Initial Sequence Number. ... Audit your website security with Acunetix Web Vulnerability Scanner: ... Up to 75% of cyber attacks are launched on shopping carts, ...
    (Pen-Test)
  • RE: Breakpoint on a web service
    ... First let us clarify how the website works. ... hosted in a web server process. ... Development Server in Visual Studio, Visual Studio will create built-in web ... I suppose that your website and web service are all ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: 2 tier vs 3 tier
    ... question is because of the following item I read on the MS website that has ... Forget about changing the DB engine as that is a ... all your data access logic sits on the web server and you end ...
    (microsoft.public.sqlserver.programming)
  • Re: IIS 6 / FrontPage Group Isolation
    ... the website using the web admin tool and the result ACL ... that the live server is using UNC for the homedirectories. ... >This is a rather recently provided handle on the FPSE ...
    (microsoft.public.inetserver.iis.security)