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
- Next message: Christopher Zacharias: "how do I code a user created subdirectory?"
- Previous message: Adam: "Re: Custom Event Log"
- In reply to: Ramiro Calderon Romero: "How can I find out whether a user has permissions to see a page or not?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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
>
>
>.
>
- Next message: Christopher Zacharias: "how do I code a user created subdirectory?"
- Previous message: Adam: "Re: Custom Event Log"
- In reply to: Ramiro Calderon Romero: "How can I find out whether a user has permissions to see a page or not?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|