2025-04-27 07:49:33 -04:00

125 lines
4.1 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=Windows-1252">
<TITLE>HasAccess</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
TempString = navigator.appVersion
if (navigator.appName == "Microsoft Internet Explorer"){
// Check to see if browser is Microsoft
if (TempString.indexOf ("4.") >= 0){
// Check to see if it is IE 4
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else {
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
}
}
else if (navigator.appName == "Netscape") {
// Check to see if browser is Netscape
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/coua.css">');
}
else
document.writeln('<link rel="stylesheet" type="text/css" href="/iishelp/common/cocss.css">');
//-->
</script>
<SCRIPT LANGUAGE="VBScript">
<!--
Sub Window_OnLoad()
Dim frmContents
On Error Resume Next
If Not Parent Is Nothing Then
Set frmContents = Parent.Contents
If Not frmContents Is Nothing Then
frmContents.Window.TOCSynch_Click
End If
End If
End Sub
//--></SCRIPT><META NAME="DESCRIPTION" CONTENT="Internet Information Services reference information">
<META HTTP-EQUIV="PICS-Label" CONTENT='(PICS-1.1 "<http://www.rsac.org/ratingsv01.html>" l comment "RSACi North America Server" by "inet@microsoft.com <mailto:inet@microsoft.com>" r (n 0 s 0 v 0 l 0))'>
<META NAME="MS.LOCALE" CONTENT="EN-US">
<META NAME="MS-IT-LOC" Content="Internet Information Services">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H2><A NAME="_hasaccess"></A><SUP></SUP>HasAccess</H2>
<P>The <B>HasAccess</B> method tests whether a user has permission to access a specified file.</P>
<H6>Syntax</H6>
<P><I>OVar</I><B>.HasAccess( </B><I>FilePath </I><B>)</B></P>
<P><B>&nbsp;</B></P>
<H6>Parameters</H6>
<DL>
<DT><I>FilePath</I></DT>
<DD>A string that specifies the path and name of the file; this can be either a physical or virtual path. </DD>
</DL>
<H6>Return Values</H6>
<P>Returns a BOOLEAN value that indicates whether the Web user has access to the specified file. If the file does not exist, or if a directory is specified, the <B>PermissionChecker</B> object returns False.</P>
<H6>Example</H6>
<P>The following example uses the <B>PermissionChecker</B> object to test whether the Web user has access to the file C:\pages\private\default.htm. If the user has access, the script creates a hyperlink to that file; otherwise it writes a message. This example uses a virtual path.</P>
<P>--- PermChecker.asp ---</P>
<PRE><CODE>&lt;%
If "" = Request.ServerVariables("LOGON_USER") Then
Response.Write "&lt;H3&gt;Please disable Anonymous Access for this Virtual Directory&lt;/H3&gt;"
Else
Set oPermChecker = Server.CreateObject("MSWC.PermissionChecker")
%&gt;
&lt;H3&gt;Checking Permissions&lt;/H3&gt;
&lt;P&gt;Logged On User =
&lt;%=Request.ServerVariables("LOGON_USER")%&gt;
&lt;P&gt;
Access to Physical Path
&lt;%=Request.ServerVariables("PATH_TRANSLATED")%&gt;
=
&lt;%=oPermChecker.HasAccess(Request.ServerVariables("PATH_TRANSLATED"))%&gt;
&lt;P&gt;
Access to Virtual Path
&lt;%=Request.ServerVariables("PATH_INFO")%&gt;
=
&lt;%=oPermChecker.HasAccess(Request.ServerVariables("PATH_INFO"))%&gt;
&lt;P&gt;
If you have access to
http://&lt;%=Request.ServerVariables("SERVER_NAME")%&gt;/iissamples/sdk/asp/simple/Variables_VBScript.asp
then you will see a link below:&lt;BR&gt;
&lt;%
If oPermChecker.HasAccess("/iissamples/sdk/asp/simple/Variables_VBScript.asp") Then
%&gt;
&lt;A href="http://localhost/iissamples/sdk/asp/simple/Variables_VBScript.asp"&gt;
http://localhost/iissamples/sdk/asp/simple/Variables_VBScript.asp
&lt;/A&gt;
&lt;%
End If
End if
%&gt;
</CODE></PRE>
<hr class="iis" size="1">
<p align="center"><em><a href="../../../common/colegal.htm">&copy; 1997-2001 Microsoft Corporation. All rights reserved.</a></em></p>
</BODY>
</HTML>