UrlAuthorizationModule.CheckUrlAccessForPrincipal(String, IPrincipal, String) 方法

定义

确定用户是否具有对所请求的文件的访问权。Determines whether the user has access to the requested file.

public:
 static bool CheckUrlAccessForPrincipal(System::String ^ virtualPath, System::Security::Principal::IPrincipal ^ user, System::String ^ verb);
public static bool CheckUrlAccessForPrincipal (string virtualPath, System.Security.Principal.IPrincipal user, string verb);
static member CheckUrlAccessForPrincipal : string * System.Security.Principal.IPrincipal * string -> bool
Public Shared Function CheckUrlAccessForPrincipal (virtualPath As String, user As IPrincipal, verb As String) As Boolean

参数

virtualPath
String

文件的虚拟路径。The virtual path to the file.

user
IPrincipal

一个表示当前用户的 IPrincipal 对象。An IPrincipal object representing the current user.

verb
String

用于进行请求的 HTTP 谓词。The HTTP verb used to make the request.

返回

如果当前用户可以访问该文件,则返回 true;否则返回 falsetrue if the current user can access the file; otherwise, false.

异常

virtualPathnullvirtualPath is null.

-or- usernulluser is null.

-or- verbnullverb is null.

virtualPath 位于应用程序根路径之外。virtualPath is outside of the application root path.

注解

CheckUrlAccessForPrincipal方法检查当前用户是否有权访问应用程序的 web.config 文件中的请求文件。The CheckUrlAccessForPrincipal method checks to see whether the current user is granted access to the requested file in the Web.config file for the application.

如果用于发出请求的 HTTP 谓词GET为、 POSTHEAD, 则该CheckUrlAccessForPrincipal方法将检查文件的读取访问权限。If the HTTP verb used to make the request is GET, POST, or HEAD, the CheckUrlAccessForPrincipal method checks for read access to the file. 如果使用任何其他谓词, 则将CheckUrlAccessForPrincipal检查对该文件的读/写访问权限。If any other verb is used, the CheckUrlAccessForPrincipal checks for read/write access to the file.

有关详细信息和示例 web.config 文件, 请参阅UrlAuthorizationModule类文档。For more information and an example Web.config file, see the UrlAuthorizationModule class documentation.

适用于