> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kasoftware.com/llms.txt
> Use this file to discover all available pages before exploring further.

# arc:restrict

> 使用 arc:restrict 根据指定用户和角色限制对服务的访问，并优先于 ASP.NET 限制。

export const siteNameShort = "知行之桥";

`arc:restrict` 关键字允许根据用户和角色限制对服务的访问。此限制优先于使用 ASP.NET 实施的任何限制。

如果在脚本中添加 `arc:restrict`，则只有指定的用户或角色可以使用该服务。

`arc:restrict` 关键字可以根据以下内容控制访问：

* 尝试执行对象集的特定用户。
* 用户是否为指定安全角色的成员，其中角色映射到 ASP.NET 身份认证和授权配置定义的角色。

<Note>单个脚本中可以有多个 `arc:restrict` 语句。它们使用逻辑 `OR` 运算符进行计算。</Note>

## 参数

* **user**：以逗号分隔的用户名列表。列表中的所有用户都可以访问对象集。
  <Note>如果使用 Windows 集成身份认证，必须确保用户名包含域或计算机限定名（例如 `DOMAIN\username`）。</Note>
* **role**：以逗号分隔的角色名称列表。任何处于至少一个指定角色中的用户都可以访问对象集。
* **authtoken**：以逗号分隔的 authtoken 列表，用于授权用户访问脚本。可以通过 HTTP Basic 身份认证、x-`arc`esb-authtoken 标头，或表单 POST 数据中的 @authtoken 提供 authtoken。如果 app\_data 文件夹中的 settings.json 设置了 AllowtokeninURL，也可以在查询字符串中提供 @authtoken。
* **visibility**：将 visibility 设置为 `local` 会使脚本无法直接从 HTTP 访问。不过，仍可以通过另一个脚本调用该脚本。
* **method**：指定用户可针对对象集执行的 HTTP 方法列表，以逗号分隔。

## 控制属性

无

## 示例

仅授予 `tomk` 和 `jdoe` 用户访问权限：

```xml theme={null}
<arc:restrict user="newton\jdoe,newton\tomk"/>
```

仅授予具有 `FeedConsumers` 角色的用户访问权限：

```xml theme={null}
<arc:restrict role="FeedConsumers"/>
```

## 另请参阅

* [arc:call](./op-arc-call)：调用脚本、操作或对象集。
