[This is preliminary documentation and subject to change]

## HasAccess

The HasAccess method tests whether a user has permission to access a specified file.

###### Syntax

OVar.HasAccess(FilePath)

###### Parameters

FilePath
  A string that specifies the path and name of the file; this can be either a physical or virtual path.

###### Return Values

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 PermissionChecker object returns False.

###### Example

The following example uses the PermissionChecker 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.

--- PermChecker.asp ---

    <%
    If "" = Request.ServerVariables("LOGON_USER") Then

      Response.Write "<H3>Please disable Anonymous Access for this Virtual Directory</H3>"

    Else

      Set oPermChecker = Server.CreateObject("MSWC.PermissionChecker")
    %>

      <H3>Checking Permissions</H3>

      <P>Logged On User =
      <%=Request.ServerVariables("LOGON_USER")%>

      <P>
      Access to Physical Path
      <%=Request.ServerVariables("PATH_TRANSLATED")%>
      =
      <%=oPermChecker.HasAccess(Request.ServerVariables("PATH_TRANSLATED"))%>

      <P>
      Access to Virtual Path
      <%=Request.ServerVariables("PATH_INFO")%>
      =
      <%=oPermChecker.HasAccess(Request.ServerVariables("PATH_INFO"))%>

      <P>
      If you have access to
      http://<%=Request.ServerVariables("SERVER_NAME")%>/iissamples/sdk/asp/simple/Variables_VBScript.asp
      then you will see a link below:<BR>

    <%
      If oPermChecker.HasAccess("/iissamples/sdk/asp/simple/Variables_VBScript.asp") Then
    %>
        <A href="http://localhost/iissamples/sdk/asp/simple/Variables_VBScript.asp">
        http://localhost/iissamples/sdk/asp/simple/Variables_VBScript.asp
        </A>
    <%
      End If

    End if
    %>

© 1997-2001 Microsoft Corporation. All rights reserved.