Name
HasAccess —
objPermChkr
.
HasAccess(
strPath
)
Synopsis
Determines whether the current user has access to the file specified
in the strPath
argument. The return value
is a Boolean.
Parameters
-
strPath
A string value that represents the relative path to the file to which you are determining accessibility. This path can be a virtual or a physical path.
Example
<%
' Declare local variables.
Dim objPermChkr
Dim blnPermission
' Instantiate a Permission Checker object.
Set objPermChkr = Server.CreateObject( _
"IISSample.PermissionChecker")
' Determine whether the current user has access to the
' security page using a virtual path.
blnPermission = objPermChkr.HasAccess("/Apps/SecPage.asp")
' Determine whether the current user has access to the
' security page using a physical path.
blnPermission = objPermChkr.HasAccess( _
"c:\inetpub\wwwroot\Apps\SecPage.asp")
. . . [addition code]
' You can then use the results of these tests to determine ' whether or not to create a hyperlink to the restricted ' page If blnPermission Then %> Congratulations, you have access to the security page. <A HREF = "/Apps/SecPage.asp">Security Page</A> <% End If %>
Notes
If the file does not exist, the call to HasAccess returns a value of
False
.
Get ASP in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.