Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 4.91 KB

File metadata and controls

80 lines (58 loc) · 4.91 KB
title IHttpFileInfo::AccessCheck Method
description Describes the IHttpFileInfo::AccessCheck method and details its syntax, parameters, return value, remarks, a code example, and requirements.
ms.date 10/07/2016
ms.assetid 87318954-5b0c-3d49-5cf5-b9d58de912a5

IHttpFileInfo::AccessCheck Method

Returns a value that indicates whether the user can access the corresponding file.

Syntax

virtual HRESULT AccessCheck(  
   IN HANDLE hUserToken,  
   IN PSID pUserSid  
) = 0;  

Parameters

hUserToken
[IN] A HANDLE that contains the token for the user.

pUserSid
[IN] A pointer that contains the security identifier (SID) for the user.

Return Value

An HRESULT. Possible values include, but are not limited to, those in the following table.

Value Definition
S_OK Indicates that the operation was successful.
E_FAIL Indicates that the operation failed.

Remarks

To determine whether the user can or cannot access the file, call either the SUCCEEDED or FAILED function, respectively, by passing the returned HRESULT from the AccessCheck method.

The behavior of the AccessCheck method is implementation specific. You should use the following information as a guideline, but it may not be correct in all scenarios:

  • Most implementers return S_OK immediately if the hUserToken parameter is NULL.

  • Most implementers return the value from calling the HRESULT_FROM_WIN32 function by supplying the value from the GetLastError function as a parameter if there are any internal errors or if the corresponding file cannot be opened.

Caution

Because most implementers return S_OK immediately if hUserToken is NULL, you should provide the user token whenever possible because the implementation may change.

Caution

While most implementers allow either or both parameters to be NULL, you should provide non-NULL values for each parameter whenever possible because the implementation may change.

Example

The following example demonstrates how to use the IHttpContext::GetFileInfo method to create an HTTP module that retrieves a pointer to an IHttpFileInfo interface for the current request. The example then calls the AccessCheck method to retrieve access information for the requested file and displays this information to a Web client.

[!code-cppIHttpFileInfo#2]

The following text is a sample of the data output from the preceding code example.

HTTP/1.1 200 OK  
content-Type:text/plain  
Server: Microsoft-IIS/7.0  
Date: Thu, 15 Dec 2005 22:22:09 GMT  
Content-Length: 348  
  
Access: -2147024891  

Your module must export the RegisterModule function. You can export this function by creating a module definition (.def) file for your project, or you can compile the module by using the /EXPORT:RegisterModule switch. For more information, see Walkthrough: Creating a Request-Level HTTP Module By Using Native Code.

You can optionally compile the code by using the __stdcall (/Gz) calling convention instead of explicitly declaring the calling convention for each function.

Requirements

Type Description
Client - IIS 7.0 on [!INCLUDEwinvista]
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on [!INCLUDEwinsrv2008]
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- [!INCLUDEiisexp75], [!INCLUDEiisexp80], [!INCLUDEiisexp100]
Header Httpserv.h

See Also

IHttpFileInfo Interface