The HasAccess method tests whether a user has permission to access a specified file.
HasAccess(FilePath)
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.
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’s 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 %>