473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Wanted: .NET equivalent of PermissionChecker component?

Hi!

Anyone knows the ASP.NET equivalent of the PermissionChecker component that
shipped with IIS 5?
Basically, what it does is checking if the current user (using
impersonation!) has access to a specified file.
I've starting playing around with the FileIOPermission class, but this
doesn't seem to do what I need (or I don't understand it).

Any help would be appreciated!

Jens
Nov 17 '05 #1
4 1500
Hello

http://msdn.microsoft.com/library/en...horization.asp

Best regards,
Sherif

"Jens Weiermann" <we******@solidsoftwareDOT.de> wrote in message
news:nf***************************@40tude.net...
Hi!

Anyone knows the ASP.NET equivalent of the PermissionChecker component that shipped with IIS 5?
Basically, what it does is checking if the current user (using
impersonation!) has access to a specified file.
I've starting playing around with the FileIOPermission class, but this
doesn't seem to do what I need (or I don't understand it).

Any help would be appreciated!

Jens

Nov 17 '05 #2
Hi Sherif,

On Wed, 12 Nov 2003 13:44:15 +0200, Sherif ElMetainy wrote:
http://msdn.microsoft.com/library/en...horization.asp


thanks for the info! However, I don't know how this should help in my case.
I *do* know that the WorkerProcess will check if the requested resource is
accessible when the page is requested. But I'd like to be able to
*programmatically* check permissions to a specific resource.

I'm using the Infragistics WebMenu component to have a nice menu. However,
some users don't have access to certain pages linked to by the menu. So,
I'd like to enumerate the menu items and see if the user does have access,
and if not disable the linked menu item.

In ASP, I would have used the permission checker component to check this;
I'm in need of a .NET way to do this...

Thanks!
Jens
Nov 17 '05 #3
Hello

If you are using impersonation, simply attempting to access the file by
openning it and catching the SecurityException can determine if the current
user has access or not.
This is a simple way, but not the most efficient. But you can cache the
results. For example, cache an array of files that the user can access, for
use in your menu.

bool HasFileAccess(string filename)
{
try
{
FileStream fs = new FileStream(filename, FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
fs.Close();
return true;
}
catch(SecurityException)
{
return false;
}
}

Otherwise I don't know of another way, except using Interop and calling
windows security API. Note that the above bethod will not work if you are
not using impersonation (i.e. the code is executing with the ASPNET
account).

Best regards,
Sherif

"Jens Weiermann" <we******@solidsoftwareDOT.de> wrote in message
news:1b****************************@40tude.net...
Hi Sherif,

On Wed, 12 Nov 2003 13:44:15 +0200, Sherif ElMetainy wrote:
http://msdn.microsoft.com/library/en...horization.asp
thanks for the info! However, I don't know how this should help in my case. I *do* know that the WorkerProcess will check if the requested resource is
accessible when the page is requested. But I'd like to be able to
*programmatically* check permissions to a specific resource.

I'm using the Infragistics WebMenu component to have a nice menu. However,
some users don't have access to certain pages linked to by the menu. So,
I'd like to enumerate the menu items and see if the user does have access,
and if not disable the linked menu item.

In ASP, I would have used the permission checker component to check this;
I'm in need of a .NET way to do this...

Thanks!
Jens

Nov 17 '05 #4
Hi Sherif,

On Wed, 12 Nov 2003 22:03:59 +0200, Sherif ElMetainy wrote:
If you are using impersonation, simply attempting to access the file by
openning it and catching the SecurityException can determine if the current
user has access or not.
this is what I tried first - but doesn't behave like expected: If the user
doesn't have access to the file, the browser will open the "logon" window
again asking for another authentication; only if this is cancelled three
times, the exception is thrown. This is sure not what I want!
Otherwise I don't know of another way, except using Interop and calling
windows security API. Note that the above bethod will not work if you are
not using impersonation (i.e. the code is executing with the ASPNET
account).


Ok, I guess that's the way to go. Do you have more details on how this
could be done using API calls?

Thanks!
Jens
Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
by: Nad | last post by:
Hello, dll hell has been eliminated in .NET using assembly versioning. I am new in .NET and would like to know if there is any dll-hell-equivalent in .NET Windows or Web development...
11
by: Capstar | last post by:
Hi, I am working on an application, which will run embedded without an OS. The app is build up out of a couple of well defined parts. At first I wanted to keep those parts seperated and use...
4
by: Mullin Yu | last post by:
I want to know what's the equivalent of COM dll at .NET platform? I want to build a .NET component and will be reused by other .NET application. Any links/sample code to teach this? Thanks!
3
by: J F | last post by:
hi all, A simple question : Is there in C# (Visual Studio .Net 2003) an equivalent to the really usefull Delphi component TFrame. (It's like a form but you can drop it on another form like any...
3
by: John | last post by:
anyone?
7
by: Marina Levit [MVP] | last post by:
Does anyone knows if this exists? Basically, a way to tell a method to execute, but a certain amount of time after the current event chain is finished - not immediately. With setTimeout, even if it...
2
by: Andrew Allen | last post by:
I need to migrate a site from Windows 2000 server running IIS5 to Windows 2003 running IIS6. The site uses extensively MSWC.PermissionChecker to control what links to show to users. The...
11
by: gnuist006 | last post by:
Is there a Delphi equivalent in the C world or Scheme/LISP world ? Recently, Delphi is in resurgence. In Russia people are using like crazy. For example, Bolega has written a free image...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.