Need help with checking file permissions.

  • Thread starter Thread starter MSDN Account
  • Start date Start date
M

MSDN Account

We have web site that used the IIS ResKit tool MSWC.PermissionChecker to
check file permissions. The web site has been upgraded and that upgrade
included changing the default server side language from VBScript to C#
(*.vbs --> *.cs).

Does C# have a native method for doing what MSWC.PermissionChecker used to
do?
If so has anyone gone through converting the MSWC.PermissionChecker method
to C# and would they share what they did?
If not has anyone converted the MSWC.PermissionChecker vbs code to C# and
would they share what they did?

I have posted the old code (some wrapping did occur) hoping it may help you
help me. if more information is need just ask me.

Thanks!
Dan Rhoads

<head>
<%
'##### July 8, 2003 SEG, POPUP Window Based on /Groupmessages/default.htm
permissions
'##### Updated 02/19/2004 by Daniel W Rhoads, The Hartford, ISD Client
Engineering
'##### Fixed the window names so more than one popup can be opened at a time
'##### they were originally all set to 'newwindow'. Converted the popups
from standard
'##### IE windows to Modal Dialogs.

Dim objPC
Dim blnUserHasAccess

Set objPC = Server.CreateObject("MSWC.PermissionChecker")

'For each message you need to copy this code block. Edit the message number
and
'ensure the NFTS file permissions are correct for the file.
blnUserHasAccess = objPC.HasAccess("./GroupMessages/Message1.htm")
If blnUserHasAccess Then %>
<SCRIPT LANGUAGE="javascript">
var sFeatures="dialogHeight:425px; dialogWidth:400px; scroll:no;
status:no; help:no;";
//var sFeatures="dialogLeft:50px; dialogTop:50px; dialogHeight:425px;
dialogWidth:400px; scroll:no; status:no; help:no;";
window.showModalDialog("./groupmessages/Message1.htm", "", sFeatures);
</SCRIPT>
<% End If
blnUserHasAccess = objPC.HasAccess("./GroupMessages/Message2.htm")
If blnUserHasAccess Then %>
<SCRIPT LANGUAGE="javascript">
var sFeatures="dialogHeight:425px; dialogWidth:400px; scroll:no;
status:no; help:no;";
//var sFeatures="dialogLeft:150px; dialogTop:150px; dialogHeight:425px;
dialogWidth:400px; scroll:no; status:no; help:no;";
window.showModalDialog("./groupmessages/Message2.htm", "", sFeatures);
</SCRIPT>
<% End If %>
</head>
 
MSDN Account said:
We have web site that used the IIS ResKit tool MSWC.PermissionChecker to
check file permissions. The web site has been upgraded and that upgrade
included changing the default server side language from VBScript to C#
(*.vbs --> *.cs).

Does C# have a native method for doing what MSWC.PermissionChecker used to
do?
If so has anyone gone through converting the MSWC.PermissionChecker method
to C# and would they share what they did?
If not has anyone converted the MSWC.PermissionChecker vbs code to C# and
would they share what they did?

I have posted the old code (some wrapping did occur) hoping it may help
you
help me. if more information is need just ask me.

Thanks!
Dan Rhoads

<head>
<%
'##### July 8, 2003 SEG, POPUP Window Based on /Groupmessages/default.htm
permissions
'##### Updated 02/19/2004 by Daniel W Rhoads, The Hartford, ISD Client
Engineering
'##### Fixed the window names so more than one popup can be opened at a
time
'##### they were originally all set to 'newwindow'. Converted the popups
from standard
'##### IE windows to Modal Dialogs.

Dim objPC
Dim blnUserHasAccess

Set objPC = Server.CreateObject("MSWC.PermissionChecker")

'For each message you need to copy this code block. Edit the message
number
and
'ensure the NFTS file permissions are correct for the file.
blnUserHasAccess = objPC.HasAccess("./GroupMessages/Message1.htm")
If blnUserHasAccess Then %>
<SCRIPT LANGUAGE="javascript">
var sFeatures="dialogHeight:425px; dialogWidth:400px; scroll:no;
status:no; help:no;";
//var sFeatures="dialogLeft:50px; dialogTop:50px; dialogHeight:425px;
dialogWidth:400px; scroll:no; status:no; help:no;";
window.showModalDialog("./groupmessages/Message1.htm", "", sFeatures);
</SCRIPT>
<% End If
blnUserHasAccess = objPC.HasAccess("./GroupMessages/Message2.htm")
If blnUserHasAccess Then %>
<SCRIPT LANGUAGE="javascript">
var sFeatures="dialogHeight:425px; dialogWidth:400px; scroll:no;
status:no; help:no;";
//var sFeatures="dialogLeft:150px; dialogTop:150px; dialogHeight:425px;
dialogWidth:400px; scroll:no; status:no; help:no;";
window.showModalDialog("./groupmessages/Message2.htm", "", sFeatures);
</SCRIPT>
<% End If %>
</head>

I would strongly suggest not to use this component, it was designed to be
used from asp and as such a STA COM component. ASP.NET runs by default as a
MTA host and using such components will require you to run in (a less
performant) aspnet compatibility mode.
If you need to know if a certain account has Read permissions for a file
(which is not needed when your site is configured correctly and you have an
authentication scheme in place) , simply open the file in read mode and
close it while impersonating.

Willy.
 
Back
Top