HasAccess

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

Syntax

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

Examples

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.

<% 
Set pmck = Server.CreateObject("MSWC.PermissionChecker") 
UserHasAccess = pmck.HasAccess("/private/default.htm")
 
If UserHasAccess 
%>
  <A HREF="/private/default.htm">Go to the Clubhouse!</A>
<% Else %>
  Sorry, you are not a member.
<% End If %>
 

The following example repeats the preceding one but uses a physical path to determine the user抯 permissions.

<% 
Set pmck = Server.CreateObject("MSWC.PermissionChecker") 
UserHasAccess = pmck.HasAccess("c:\pages\private\default.htm")
 
If UserHasAccess 
%>
  <A HREF="/private/default.htm">Go to the Clubhouse!</A>
<% Else %>
  Sorry, you are not a member.
<% End If %>